Fix text offset in the expanded deleted hunk (#11295)
This commit is contained in:
parent
23f191450e
commit
aeff468e9c
3 changed files with 8 additions and 7 deletions
|
@ -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 {
|
||||
|
|
|
@ -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.));
|
||||
|
||||
|
|
|
@ -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()
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue