From 65f72387771e320e323eca72bc4ccc170ebf8e41 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 8 May 2024 13:44:09 +0200 Subject: [PATCH] editor: Fix task indicator layout for wrapped lines --- crates/editor/src/editor.rs | 16 ++++++---------- crates/editor/src/element.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index af64c5f0d24cf001ad8b6a88787fcf6c9d205244..7e6b2b3573e65646f49b50f5a0407e7ba8dddecd 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7738,12 +7738,7 @@ impl Editor { } }) .await; - let rows = Self::refresh_runnable_display_rows( - project, - display_snapshot, - new_rows, - cx.clone(), - ); + let rows = Self::runnable_rows(project, display_snapshot, new_rows, cx.clone()); this.update(&mut cx, |this, _| { this.clear_tasks(); @@ -7760,7 +7755,8 @@ impl Editor { ) -> Vec<(Range, Runnable)> { snapshot.buffer_snapshot.runnable_ranges(range).collect() } - fn refresh_runnable_display_rows( + + fn runnable_rows( project: Model, snapshot: DisplaySnapshot, runnable_ranges: Vec<(Range, Runnable)>, @@ -7775,12 +7771,12 @@ impl Editor { if tasks.is_empty() { return None; } - let point = multi_buffer_range.start.to_display_point(&snapshot); + let point = multi_buffer_range.start.to_point(&snapshot.buffer_snapshot); Some(( - point.row(), + point.row, RunnableTasks { templates: tasks, - column: point.column(), + column: point.column, }, )) }) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 2c54a03ed9a687cd1093fcda249a9901ce9ba783..1872952990c98f2aa712e9a9bb5d994e9f3d8320 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1381,6 +1381,7 @@ impl EditorElement { scroll_pixel_position: gpui::Point, gutter_dimensions: &GutterDimensions, gutter_hitbox: &Hitbox, + snapshot: &EditorSnapshot, cx: &mut WindowContext, ) -> Vec { self.editor.update(cx, |editor, cx| { @@ -1409,10 +1410,12 @@ impl EditorElement { *row, cx, ); - + let display_row = Point::new(*row, 0) + .to_display_point(&snapshot.display_snapshot) + .row(); let button = prepaint_gutter_button( button, - *row, + display_row, line_height, gutter_dimensions, scroll_pixel_position, @@ -4043,6 +4046,7 @@ impl Element for EditorElement { scroll_pixel_position, &gutter_dimensions, &gutter_hitbox, + &snapshot, cx, );