Fix pairs of almost-adjacent hunks toggling together (#24355)
Release Notes: - Fixed a bug where toggling a diff hunk that immediately precedes another hunk would act on both hunks
This commit is contained in:
parent
a42e040660
commit
d97adfc540
3 changed files with 56 additions and 17 deletions
|
@ -12237,11 +12237,19 @@ impl Editor {
|
|||
cx: &mut Context<'_, Editor>,
|
||||
) {
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
if buffer.has_expanded_diff_hunks_in_ranges(&ranges, cx) {
|
||||
buffer.collapse_diff_hunks(ranges, cx)
|
||||
} else {
|
||||
buffer.expand_diff_hunks(ranges, cx)
|
||||
}
|
||||
let expand = !buffer.has_expanded_diff_hunks_in_ranges(&ranges, cx);
|
||||
buffer.expand_or_collapse_diff_hunks(ranges, expand, cx);
|
||||
})
|
||||
}
|
||||
|
||||
fn toggle_diff_hunks_in_ranges_narrow(
|
||||
&mut self,
|
||||
ranges: Vec<Range<Anchor>>,
|
||||
cx: &mut Context<'_, Editor>,
|
||||
) {
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
let expand = !buffer.has_expanded_diff_hunks_in_ranges(&ranges, cx);
|
||||
buffer.expand_or_collapse_diff_hunks_narrow(ranges, expand, cx);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -559,7 +559,7 @@ impl EditorElement {
|
|||
let mut modifiers = event.modifiers;
|
||||
|
||||
if let Some(hovered_hunk) = hovered_hunk {
|
||||
editor.toggle_diff_hunks_in_ranges(vec![hovered_hunk], cx);
|
||||
editor.toggle_diff_hunks_in_ranges_narrow(vec![hovered_hunk], cx);
|
||||
cx.notify();
|
||||
return;
|
||||
} else if gutter_hitbox.is_hovered(window) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue