Do not select target range going to definition (#11691)
Release Notes: -Fixed #11347 , do not select target range going to definition. Just place the cursor at the start of target range.
This commit is contained in:
parent
d3dfa91254
commit
c3c4e37940
1 changed files with 20 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue