diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 86ed6d71b83cbc8f1fa8e5a2ae8c54c6cf08063f..61e1d5839f8daa47cf4820d7d2e093ab017b8f7c 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, pixel_position_of_newest_cursor: Option>, - gutter_width: Pixels, + gutter_dimensions: GutterDimensions, pub vim_replace_map: HashMap, String>, style: Option, editor_actions: Vec)>>, @@ -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.rs index 15f2be0e8b4a00d3e252a2cf812093192049ceba..eaed495c81c0685ecf8c6fcf42a2ace4e74cf48b 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.rs index 7f5895eae0f5ace14726a0831220e71e11d727fc..e2ca19a567686542a8f4d23b3fef56e625e75234 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() }),