diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a4a8a5e02baad4e3306278ed11709d3527e868ce..f70693a8d674b81f876d2fe779c5a1a9dda56212 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -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() })); }, );