Only autoscroll on select_next operations
This commit is contained in:
@@ -5957,16 +5957,18 @@ impl Editor {
|
|||||||
&mut self,
|
&mut self,
|
||||||
display_map: &DisplaySnapshot,
|
display_map: &DisplaySnapshot,
|
||||||
replace_newest: bool,
|
replace_newest: bool,
|
||||||
|
autoscroll: Option<Autoscroll>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
fn select_next_match_ranges(
|
fn select_next_match_ranges(
|
||||||
this: &mut Editor,
|
this: &mut Editor,
|
||||||
range: Range<usize>,
|
range: Range<usize>,
|
||||||
replace_newest: bool,
|
replace_newest: bool,
|
||||||
|
auto_scroll: Option<Autoscroll>,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
this.unfold_ranges([range.clone()], false, true, cx);
|
this.unfold_ranges([range.clone()], false, true, cx);
|
||||||
this.change_selections(Some(Autoscroll::newest()), cx, |s| {
|
this.change_selections(auto_scroll, cx, |s| {
|
||||||
if replace_newest {
|
if replace_newest {
|
||||||
s.delete(s.newest_anchor().id);
|
s.delete(s.newest_anchor().id);
|
||||||
}
|
}
|
||||||
@@ -6018,7 +6020,13 @@ impl Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(next_selected_range) = next_selected_range {
|
if let Some(next_selected_range) = next_selected_range {
|
||||||
select_next_match_ranges(self, next_selected_range, replace_newest, cx);
|
select_next_match_ranges(
|
||||||
|
self,
|
||||||
|
next_selected_range,
|
||||||
|
replace_newest,
|
||||||
|
autoscroll,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
select_next_state.done = true;
|
select_next_state.done = true;
|
||||||
}
|
}
|
||||||
@@ -6045,7 +6053,13 @@ impl Editor {
|
|||||||
wordwise: true,
|
wordwise: true,
|
||||||
done: false,
|
done: false,
|
||||||
};
|
};
|
||||||
select_next_match_ranges(self, selection.start..selection.end, replace_newest, cx);
|
select_next_match_ranges(
|
||||||
|
self,
|
||||||
|
selection.start..selection.end,
|
||||||
|
replace_newest,
|
||||||
|
autoscroll,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
self.select_next_state = Some(select_state);
|
self.select_next_state = Some(select_state);
|
||||||
} else {
|
} else {
|
||||||
let query = buffer
|
let query = buffer
|
||||||
@@ -6056,7 +6070,7 @@ impl Editor {
|
|||||||
wordwise: false,
|
wordwise: false,
|
||||||
done: false,
|
done: false,
|
||||||
});
|
});
|
||||||
self.select_next_match_internal(display_map, replace_newest, cx)?;
|
self.select_next_match_internal(display_map, replace_newest, autoscroll, cx)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -6071,7 +6085,7 @@ impl Editor {
|
|||||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
self.select_next_match_internal(&display_map, action.replace_newest, cx)?;
|
self.select_next_match_internal(&display_map, action.replace_newest, None, cx)?;
|
||||||
|
|
||||||
if self
|
if self
|
||||||
.select_next_state
|
.select_next_state
|
||||||
@@ -6089,7 +6103,12 @@ impl Editor {
|
|||||||
pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) -> Result<()> {
|
pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) -> Result<()> {
|
||||||
self.push_to_selection_history();
|
self.push_to_selection_history();
|
||||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
self.select_next_match_internal(&display_map, action.replace_newest, cx)?;
|
self.select_next_match_internal(
|
||||||
|
&display_map,
|
||||||
|
action.replace_newest,
|
||||||
|
Some(Autoscroll::newest()),
|
||||||
|
cx,
|
||||||
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user