Compare commits

...

4 Commits

Author SHA1 Message Date
Agus Zubiaga
57d09d2fd3 zed 0.173.1 2025-02-04 18:50:01 -03:00
Agus Zubiaga
bc67f990ae 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
2025-02-04 18:48:30 -03:00
Agus Zubiaga
722fd59d9c edit prediction: Do not render jump cursor until line layout is ready (#24226)
This is pretty rare but I found a case where `line_layouts` didn't have
the requested line yet, so we now skip rendering the cursor for that
period and avoid panicking.

Release Notes:

- N/A
2025-02-04 18:11:59 -03:00
Peter Tripp
cf4e294007 v0.173.x preview 2025-02-04 14:36:32 -05:00
5 changed files with 26 additions and 17 deletions

2
Cargo.lock generated
View File

@@ -16411,7 +16411,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.173.0"
version = "0.173.1"
dependencies = [
"activity_indicator",
"anyhow",

View File

@@ -5418,6 +5418,7 @@ impl Editor {
min_width: Pixels,
max_width: Pixels,
cursor_point: Point,
start_row: DisplayRow,
line_layouts: &[LineWithInvisibles],
style: &EditorStyle,
accept_keystroke: &gpui::Keystroke,
@@ -5470,6 +5471,7 @@ impl Editor {
Some(completion) => self.render_edit_prediction_cursor_popover_preview(
completion,
cursor_point,
start_row,
line_layouts,
style,
cx,
@@ -5479,6 +5481,7 @@ impl Editor {
Some(stale_completion) => self.render_edit_prediction_cursor_popover_preview(
stale_completion,
cursor_point,
start_row,
line_layouts,
style,
cx,
@@ -5565,6 +5568,7 @@ impl Editor {
&self,
completion: &InlineCompletionState,
cursor_point: Point,
start_row: DisplayRow,
line_layouts: &[LineWithInvisibles],
style: &EditorStyle,
cx: &mut Context<Editor>,
@@ -5672,11 +5676,13 @@ impl Editor {
let end_point = range_around_target.end.to_point(&snapshot);
let target_point = target.text_anchor.to_point(&snapshot);
let start_column_x =
line_layouts[start_point.row as usize].x_for_index(start_point.column as usize);
let target_column_x = line_layouts[target_point.row as usize]
.x_for_index(target_point.column as usize);
let cursor_relative_position = target_column_x - start_column_x;
let cursor_relative_position = line_layouts
.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 target_column_x = line.x_for_index(target_point.column as usize);
target_column_x - start_column_x
});
let fade_before = start_point.column > 0;
let fade_after = end_point.column < snapshot.line_len(end_point.row);
@@ -5719,15 +5725,17 @@ impl Editor {
),
)
})
.child(
div()
.w(px(2.))
.h_full()
.bg(cursor_color)
.absolute()
.top_0()
.left(cursor_relative_position),
),
.when_some(cursor_relative_position, |parent, position| {
parent.child(
div()
.w(px(2.))
.h_full()
.bg(cursor_color)
.absolute()
.top_0()
.left(position),
)
}),
)
}),
)

View File

@@ -3300,6 +3300,7 @@ impl EditorElement {
min_width,
max_width,
cursor_point,
start_row,
&line_layouts,
style,
accept_keystroke.as_ref()?,

View File

@@ -2,7 +2,7 @@
description = "The fast, collaborative code editor."
edition.workspace = true
name = "zed"
version = "0.173.0"
version = "0.173.1"
publish.workspace = true
license = "GPL-3.0-or-later"
authors = ["Zed Team <hi@zed.dev>"]

View File

@@ -1 +1 @@
dev
preview