Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Do not select target range going to definition (#11691)
Congyuc3c4e37940b9
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 5efc578eff4..2d98f8c3f9d 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -8365,7 +8365,25 @@ impl Editor {let range = target.range.to_offset(target.buffer.read(cx));let range = editor.range_for_match(&range);++ /// If select range has more than one line, we+ /// just point the cursor to range.start.+ fn check_multiline_range(+ buffer: &Buffer,+ range: Range<usize>,+ ) -> Range<usize> {+ if buffer.offset_to_point(range.start).row+ == buffer.offset_to_point(range.end).row+ {+ range+ } else {+ range.start..range.start+ }+ }+if Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref() {+ let buffer = target.buffer.read(cx);+ let range = check_multiline_range(buffer, range);editor.change_selections(Some(Autoscroll::focused()), cx, |s| {s.select_ranges([range]);});@@ -8385,6 +8403,8 @@ impl Editor {// When selecting a definition in a different buffer, disable the nav history// to avoid creating a history entry at the previous cursor location.pane.update(cx, |pane, _| pane.disable_history());+ let buffer = target.buffer.read(cx);+ let range = check_multiline_range(buffer, range);target_editor.change_selections(Some(Autoscroll::focused()),cx,