edit prediction: Fix jump cursor position when scrolled (#24230)
We were looking up line layouts without subtracting start row so we would get the wrong one when scrolled Release Notes: - N/A
This commit is contained in:
parent
b02baea9d2
commit
b13498a5dd
2 changed files with 8 additions and 2 deletions
|
@ -5421,6 +5421,7 @@ impl Editor {
|
||||||
min_width: Pixels,
|
min_width: Pixels,
|
||||||
max_width: Pixels,
|
max_width: Pixels,
|
||||||
cursor_point: Point,
|
cursor_point: Point,
|
||||||
|
start_row: DisplayRow,
|
||||||
line_layouts: &[LineWithInvisibles],
|
line_layouts: &[LineWithInvisibles],
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
accept_keystroke: &gpui::Keystroke,
|
accept_keystroke: &gpui::Keystroke,
|
||||||
|
@ -5473,6 +5474,7 @@ impl Editor {
|
||||||
Some(completion) => self.render_edit_prediction_cursor_popover_preview(
|
Some(completion) => self.render_edit_prediction_cursor_popover_preview(
|
||||||
completion,
|
completion,
|
||||||
cursor_point,
|
cursor_point,
|
||||||
|
start_row,
|
||||||
line_layouts,
|
line_layouts,
|
||||||
style,
|
style,
|
||||||
cx,
|
cx,
|
||||||
|
@ -5482,6 +5484,7 @@ impl Editor {
|
||||||
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
|
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
|
||||||
stale_completion,
|
stale_completion,
|
||||||
cursor_point,
|
cursor_point,
|
||||||
|
start_row,
|
||||||
line_layouts,
|
line_layouts,
|
||||||
style,
|
style,
|
||||||
cx,
|
cx,
|
||||||
|
@ -5568,6 +5571,7 @@ impl Editor {
|
||||||
&self,
|
&self,
|
||||||
completion: &InlineCompletionState,
|
completion: &InlineCompletionState,
|
||||||
cursor_point: Point,
|
cursor_point: Point,
|
||||||
|
start_row: DisplayRow,
|
||||||
line_layouts: &[LineWithInvisibles],
|
line_layouts: &[LineWithInvisibles],
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
|
@ -5675,8 +5679,9 @@ impl Editor {
|
||||||
let end_point = range_around_target.end.to_point(&snapshot);
|
let end_point = range_around_target.end.to_point(&snapshot);
|
||||||
let target_point = target.text_anchor.to_point(&snapshot);
|
let target_point = target.text_anchor.to_point(&snapshot);
|
||||||
|
|
||||||
let cursor_relative_position =
|
let cursor_relative_position = line_layouts
|
||||||
line_layouts.get(start_point.row as usize).map(|line| {
|
.get(start_point.row.saturating_sub(start_row.0) as usize)
|
||||||
|
.map(|line| {
|
||||||
let start_column_x = line.x_for_index(start_point.column as usize);
|
let start_column_x = line.x_for_index(start_point.column as usize);
|
||||||
let target_column_x = line.x_for_index(target_point.column as usize);
|
let target_column_x = line.x_for_index(target_point.column as usize);
|
||||||
target_column_x - start_column_x
|
target_column_x - start_column_x
|
||||||
|
|
|
@ -3285,6 +3285,7 @@ impl EditorElement {
|
||||||
min_width,
|
min_width,
|
||||||
max_width,
|
max_width,
|
||||||
cursor_point,
|
cursor_point,
|
||||||
|
start_row,
|
||||||
&line_layouts,
|
&line_layouts,
|
||||||
style,
|
style,
|
||||||
accept_keystroke.as_ref()?,
|
accept_keystroke.as_ref()?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue