Revert "Remove into SelectionEffects from .change_selections"

This reverts commit 28380d714d.
This commit is contained in:
Conrad Irwin 2025-06-27 14:06:17 -06:00
parent 28380d714d
commit 6e762d9c05
65 changed files with 625 additions and 837 deletions

View file

@ -2,9 +2,10 @@ use anyhow::Result;
use collections::{HashMap, HashSet};
use command_palette_hooks::CommandInterceptResult;
use editor::{
Bias, Editor, SelectionEffects, ToPoint,
Bias, Editor, ToPoint,
actions::{SortLinesCaseInsensitive, SortLinesCaseSensitive},
display_map::ToDisplayPoint,
scroll::Autoscroll,
};
use gpui::{Action, App, AppContext as _, Context, Global, Window, actions};
use itertools::Itertools;
@ -421,7 +422,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
let target = snapshot
.buffer_snapshot
.clip_point(Point::new(buffer_row.0, current.head().column), Bias::Left);
editor.change_selections(Default::default(), window, cx, |s| {
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
s.select_ranges([target..target]);
});
@ -492,7 +493,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
.disjoint_anchor_ranges()
.collect::<Vec<_>>()
});
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
editor.change_selections(None, window, cx, |s| {
let end = Point::new(range.end.0, s.buffer().line_len(range.end));
s.select_ranges([end..Point::new(range.start.0, 0)]);
});
@ -502,7 +503,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
window.dispatch_action(action.action.boxed_clone(), cx);
cx.defer_in(window, move |vim, window, cx| {
vim.update_editor(window, cx, |_, editor, window, cx| {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
editor.change_selections(None, window, cx, |s| {
if let Some(previous_selections) = previous_selections {
s.select_ranges(previous_selections);
} else {
@ -1454,20 +1455,15 @@ impl OnMatchingLines {
editor
.update_in(cx, |editor, window, cx| {
editor.start_transaction_at(Instant::now(), window, cx);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
editor.change_selections(None, window, cx, |s| {
s.replace_cursors_with(|_| new_selections);
});
window.dispatch_action(action, cx);
cx.defer_in(window, move |editor, window, cx| {
let newest = editor.selections.newest::<Point>(cx).clone();
editor.change_selections(
SelectionEffects::no_scroll(),
window,
cx,
|s| {
s.select(vec![newest]);
},
);
editor.change_selections(None, window, cx, |s| {
s.select(vec![newest]);
});
editor.end_transaction_at(Instant::now(), cx);
})
})
@ -1570,7 +1566,7 @@ impl Vim {
)
.unwrap_or((start.range(), MotionKind::Exclusive));
if range.start != start.start {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
editor.change_selections(None, window, cx, |s| {
s.select_ranges([
range.start.to_point(&snapshot)..range.start.to_point(&snapshot)
]);
@ -1610,7 +1606,7 @@ impl Vim {
.range(&snapshot, start.clone(), around)
.unwrap_or(start.range());
if range.start != start.start {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
editor.change_selections(None, window, cx, |s| {
s.select_ranges([
range.start.to_point(&snapshot)..range.start.to_point(&snapshot)
]);
@ -1803,7 +1799,7 @@ impl ShellExec {
editor.transact(window, cx, |editor, window, cx| {
editor.edit([(range.clone(), text)], cx);
let snapshot = editor.buffer().read(cx).snapshot(cx);
editor.change_selections(Default::default(), window, cx, |s| {
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
let point = if is_read {
let point = range.end.to_point(&snapshot);
Point::new(point.row.saturating_sub(1), 0)