Skip to content

Commit

Permalink
Use multi buffer for showing the removed lines diff
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneToIgnore committed Apr 30, 2024
1 parent 122afba commit daad9ff
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 104 deletions.
47 changes: 26 additions & 21 deletions crates/editor/src/display_map/block_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,28 +364,33 @@ impl BlockMap {
(position.row(), TransformBlock::Custom(block.clone()))
}),
);
blocks_in_edit.extend(
buffer
.excerpt_boundaries_in_range((start_bound, end_bound))
.map(|excerpt_boundary| {
(
wrap_snapshot
.make_wrap_point(Point::new(excerpt_boundary.row, 0), Bias::Left)
.row(),
TransformBlock::ExcerptHeader {
id: excerpt_boundary.id,
buffer: excerpt_boundary.buffer,
range: excerpt_boundary.range,
height: if excerpt_boundary.starts_new_buffer {
self.buffer_header_height
} else {
self.excerpt_header_height
if buffer.show_headers() {
blocks_in_edit.extend(
buffer
.excerpt_boundaries_in_range((start_bound, end_bound))
.map(|excerpt_boundary| {
(
wrap_snapshot
.make_wrap_point(
Point::new(excerpt_boundary.row, 0),
Bias::Left,
)
.row(),
TransformBlock::ExcerptHeader {
id: excerpt_boundary.id,
buffer: excerpt_boundary.buffer,
range: excerpt_boundary.range,
height: if excerpt_boundary.starts_new_buffer {
self.buffer_header_height
} else {
self.excerpt_header_height
},
starts_new_buffer: excerpt_boundary.starts_new_buffer,
},
starts_new_buffer: excerpt_boundary.starts_new_buffer,
},
)
}),
);
)
}),
);
}

// Place excerpt headers above custom blocks on the same row.
blocks_in_edit.sort_unstable_by(|(row_a, block_a), (row_b, block_b)| {
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl EditorElement {
if gutter_hitbox.is_hovered(cx) {
click_count = 3; // Simulate triple-click when clicking the gutter to select lines
} else if let Some(hovered_hunk) = hovered_hunk {
editor.expand_diff_hunk(hovered_hunk, cx);
editor.expand_diff_hunk(None, hovered_hunk, cx);
} else if !text_hitbox.is_hovered(cx) {
return;
}
Expand Down

0 comments on commit daad9ff

Please sign in to comment.