Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix text offset in the expanded deleted hunk (#11295)
Kirill Bulatovaeff468e9c45
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 86ed6d71b83..61e1d5839f8 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -467,7 +467,7 @@ pub struct Editor {next_inlay_id: usize,_subscriptions: Vec<Subscription>,pixel_position_of_newest_cursor: Option<gpui::Point<Pixels>>,- gutter_width: Pixels,+ gutter_dimensions: GutterDimensions,pub vim_replace_map: HashMap<Range<usize>, String>,style: Option<EditorStyle>,editor_actions: Vec<Box<dyn Fn(&mut ViewContext<Self>)>>,@@ -503,6 +503,7 @@ pub struct EditorSnapshot {const GIT_BLAME_GUTTER_WIDTH_CHARS: f32 = 53.;+#[derive(Debug, Clone, Copy)]pub struct GutterDimensions {pub left_padding: Pixels,pub right_padding: Pixels,@@ -1517,7 +1518,7 @@ impl Editor {pixel_position_of_newest_cursor: None,last_bounds: None,expect_bounds_change: None,- gutter_width: Default::default(),+ gutter_dimensions: GutterDimensions::default(),style: None,show_cursor_names: false,hovered_cursors: Default::default(),@@ -10807,7 +10808,7 @@ impl ViewInputHandler for Editor {let start = OffsetUtf16(range_utf16.start).to_display_point(&snapshot);let x = snapshot.x_for_display_point(start, &text_layout_details) - scroll_left- + self.gutter_width;+ + self.gutter_dimensions.width;let y = line_height * (start.row() as f32 - scroll_position.y);Some(Bounds {diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 15f2be0e8b4..eaed495c81c 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -3644,7 +3644,7 @@ impl Element for EditorElement {snapshot = self.editor.update(cx, |editor, cx| {editor.last_bounds = Some(bounds);- editor.gutter_width = gutter_dimensions.width;+ editor.gutter_dimensions = gutter_dimensions;editor.set_visible_line_count(bounds.size.height / line_height, cx);let editor_width =@@ -5157,7 +5157,7 @@ fn compute_auto_height_layout(let gutter_dimensions =snapshot.gutter_dimensions(font_id, font_size, em_width, max_line_number_width, cx);- editor.gutter_width = gutter_dimensions.width;+ editor.gutter_dimensions = gutter_dimensions;let text_width = width - gutter_dimensions.width;let overscroll = size(em_width, px(0.));diff --git a/crates/editor/src/hunk_diff.rs b/crates/editor/src/hunk_diff.rsindex 7f5895eae0f..e2ca19a5676 100644--- a/crates/editor/src/hunk_diff.rs+++ b/crates/editor/src/hunk_diff.rs@@ -332,7 +332,7 @@ impl Editor {let deleted_hunk_color = deleted_hunk_color(cx);let (editor_height, editor_with_deleted_text) =editor_with_deleted_text(diff_base_buffer, deleted_text_range, deleted_hunk_color, cx);- let parent_gutter_width = self.gutter_width;+ let parent_gutter_offset = self.gutter_dimensions.width + self.gutter_dimensions.margin;let mut new_block_ids = self.insert_blocks(Some(BlockProperties {position,@@ -342,7 +342,7 @@ impl Editor {div().bg(deleted_hunk_color).size_full()- .pl(parent_gutter_width)+ .pl(parent_gutter_offset).child(editor_with_deleted_text.clone()).into_any_element()}),