Remove into SelectionEffects
from .change_selections
In #32656 I generalized the argument to change selections to allow controling both the scroll and the nav history (and the completion trigger). To avoid conflicting with ongoing debugger cherry-picks I left the argument as an `impl Into<>`, but I think it's clearer to make callers specify what they want here. I converted a lot of `None` arguments to `SelectionEffects::no_scroll()` to be exactly compatible; but I think many people used none as an "i don't care" value in which case Default::default() might be more appropraite
This commit is contained in:
parent
f338c46bf7
commit
28380d714d
65 changed files with 837 additions and 625 deletions
|
@ -1540,7 +1540,10 @@ mod tests {
|
|||
use std::ops::Range;
|
||||
|
||||
use super::*;
|
||||
use editor::{DisplayPoint, Editor, MultiBuffer, SearchSettings, display_map::DisplayRow};
|
||||
use editor::{
|
||||
DisplayPoint, Editor, MultiBuffer, SearchSettings, SelectionEffects,
|
||||
display_map::DisplayRow,
|
||||
};
|
||||
use gpui::{Hsla, TestAppContext, UpdateGlobal, VisualTestContext};
|
||||
use language::{Buffer, Point};
|
||||
use project::Project;
|
||||
|
@ -1677,7 +1680,7 @@ mod tests {
|
|||
});
|
||||
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)
|
||||
])
|
||||
|
@ -1764,7 +1767,7 @@ mod tests {
|
|||
// Park the cursor in between matches and ensure that going to the previous match selects
|
||||
// the closest match to the left.
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0)
|
||||
])
|
||||
|
@ -1785,7 +1788,7 @@ mod tests {
|
|||
// Park the cursor in between matches and ensure that going to the next match selects the
|
||||
// closest match to the right.
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(1), 0)..DisplayPoint::new(DisplayRow(1), 0)
|
||||
])
|
||||
|
@ -1806,7 +1809,7 @@ mod tests {
|
|||
// Park the cursor after the last match and ensure that going to the previous match selects
|
||||
// the last match.
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(3), 60)..DisplayPoint::new(DisplayRow(3), 60)
|
||||
])
|
||||
|
@ -1827,7 +1830,7 @@ mod tests {
|
|||
// Park the cursor after the last match and ensure that going to the next match selects the
|
||||
// first match.
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(3), 60)..DisplayPoint::new(DisplayRow(3), 60)
|
||||
])
|
||||
|
@ -1848,7 +1851,7 @@ mod tests {
|
|||
// Park the cursor before the first match and ensure that going to the previous match
|
||||
// selects the last match.
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_display_ranges([
|
||||
DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)
|
||||
])
|
||||
|
@ -2625,7 +2628,7 @@ mod tests {
|
|||
});
|
||||
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges(vec![Point::new(1, 0)..Point::new(2, 4)])
|
||||
})
|
||||
});
|
||||
|
@ -2708,7 +2711,7 @@ mod tests {
|
|||
});
|
||||
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges(vec![
|
||||
Point::new(1, 0)..Point::new(1, 4),
|
||||
Point::new(5, 3)..Point::new(6, 4),
|
||||
|
|
|
@ -7,7 +7,7 @@ use anyhow::Context as _;
|
|||
use collections::{HashMap, HashSet};
|
||||
use editor::{
|
||||
Anchor, Editor, EditorElement, EditorEvent, EditorSettings, EditorStyle, MAX_TAB_TITLE_LEN,
|
||||
MultiBuffer, actions::SelectAll, items::active_match_index, scroll::Autoscroll,
|
||||
MultiBuffer, SelectionEffects, actions::SelectAll, items::active_match_index,
|
||||
};
|
||||
use futures::{StreamExt, stream::FuturesOrdered};
|
||||
use gpui::{
|
||||
|
@ -1303,7 +1303,7 @@ impl ProjectSearchView {
|
|||
self.results_editor.update(cx, |editor, cx| {
|
||||
let range_to_select = editor.range_for_match(&range_to_select);
|
||||
editor.unfold_ranges(std::slice::from_ref(&range_to_select), false, true, cx);
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
s.select_ranges([range_to_select])
|
||||
});
|
||||
});
|
||||
|
@ -1350,7 +1350,9 @@ impl ProjectSearchView {
|
|||
fn focus_results_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.query_editor.update(cx, |query_editor, cx| {
|
||||
let cursor = query_editor.selections.newest_anchor().head();
|
||||
query_editor.change_selections(None, window, cx, |s| s.select_ranges([cursor..cursor]));
|
||||
query_editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([cursor..cursor])
|
||||
});
|
||||
});
|
||||
let results_handle = self.results_editor.focus_handle(cx);
|
||||
window.focus(&results_handle);
|
||||
|
@ -1370,7 +1372,7 @@ impl ProjectSearchView {
|
|||
let range_to_select = match_ranges
|
||||
.first()
|
||||
.map(|range| editor.range_for_match(range));
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
s.select_ranges(range_to_select)
|
||||
});
|
||||
editor.scroll(Point::default(), Some(Axis::Vertical), window, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue