Fix selections when opening excerpt with an existing buffer that has expanded diff hunks (#44360)
Release Notes: - N/A
This commit is contained in:
@@ -22102,14 +22102,23 @@ impl Editor {
|
||||
None => Autoscroll::newest(),
|
||||
};
|
||||
let nav_history = editor.nav_history.take();
|
||||
let multibuffer_snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let Some((&excerpt_id, _, buffer_snapshot)) =
|
||||
multibuffer_snapshot.as_singleton()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
editor.change_selections(
|
||||
SelectionEffects::scroll(autoscroll),
|
||||
window,
|
||||
cx,
|
||||
|s| {
|
||||
s.select_ranges(ranges.into_iter().map(|range| {
|
||||
// we checked that the editor is a singleton editor so the offsets are valid
|
||||
MultiBufferOffset(range.start.0)..MultiBufferOffset(range.end.0)
|
||||
let range = buffer_snapshot.anchor_before(range.start)
|
||||
..buffer_snapshot.anchor_after(range.end);
|
||||
multibuffer_snapshot
|
||||
.anchor_range_in_excerpt(excerpt_id, range)
|
||||
.unwrap()
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user