Revert "Remove into SelectionEffects
from .change_selections"
This reverts commit 28380d714d
.
This commit is contained in:
parent
28380d714d
commit
6e762d9c05
65 changed files with 625 additions and 837 deletions
|
@ -26,6 +26,7 @@ use collections::BTreeSet;
|
|||
use convert::ConvertTarget;
|
||||
use editor::Bias;
|
||||
use editor::Editor;
|
||||
use editor::scroll::Autoscroll;
|
||||
use editor::{Anchor, SelectionEffects};
|
||||
use editor::{display_map::ToDisplayPoint, movement};
|
||||
use gpui::{Context, Window, actions};
|
||||
|
@ -102,7 +103,7 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
|
|||
Vim::action(editor, cx, |vim, _: &HelixDelete, window, cx| {
|
||||
vim.record_current_action(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| {
|
||||
s.move_with(|map, selection| {
|
||||
if selection.is_empty() {
|
||||
selection.end = movement::right(map, selection.end)
|
||||
|
@ -376,7 +377,7 @@ impl Vim {
|
|||
self.start_recording(cx);
|
||||
self.switch_mode(Mode::Insert, false, window, cx);
|
||||
self.update_editor(window, cx, |_, editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_cursors_with(|map, cursor, _| (right(map, cursor, 1), SelectionGoal::None));
|
||||
});
|
||||
});
|
||||
|
@ -387,7 +388,7 @@ impl Vim {
|
|||
if self.mode.is_visual() {
|
||||
let current_mode = self.mode;
|
||||
self.update_editor(window, cx, |_, editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
if current_mode == Mode::VisualLine {
|
||||
let start_of_line = motion::start_of_line(map, false, selection.start);
|
||||
|
@ -411,7 +412,7 @@ impl Vim {
|
|||
self.start_recording(cx);
|
||||
self.switch_mode(Mode::Insert, false, window, cx);
|
||||
self.update_editor(window, cx, |_, editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_cursors_with(|map, cursor, _| {
|
||||
(
|
||||
first_non_whitespace(map, false, cursor),
|
||||
|
@ -431,7 +432,7 @@ impl Vim {
|
|||
self.start_recording(cx);
|
||||
self.switch_mode(Mode::Insert, false, window, cx);
|
||||
self.update_editor(window, cx, |_, editor, window, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_cursors_with(|map, cursor, _| {
|
||||
(next_line_end(map, cursor, 1), SelectionGoal::None)
|
||||
});
|
||||
|
@ -452,7 +453,7 @@ impl Vim {
|
|||
return;
|
||||
};
|
||||
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.select_anchor_ranges(marks.iter().map(|mark| *mark..*mark))
|
||||
});
|
||||
});
|
||||
|
@ -488,7 +489,7 @@ impl Vim {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
editor.edit_with_autoindent(edits, cx);
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_cursors_with(|map, cursor, _| {
|
||||
let previous_line = motion::start_of_relative_buffer_row(map, cursor, -1);
|
||||
let insert_point = motion::end_of_line(map, false, previous_line, 1);
|
||||
|
@ -529,7 +530,7 @@ impl Vim {
|
|||
(end_of_line..end_of_line, "\n".to_string() + &indent)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.maybe_move_cursors_with(|map, cursor, goal| {
|
||||
Motion::CurrentLine.move_point(
|
||||
map,
|
||||
|
@ -606,7 +607,7 @@ impl Vim {
|
|||
.collect::<Vec<_>>();
|
||||
editor.edit(edits, cx);
|
||||
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
s.move_with(|_, selection| {
|
||||
if let Some(position) = original_positions.get(&selection.id) {
|
||||
selection.collapse_to(*position, SelectionGoal::None);
|
||||
|
@ -754,7 +755,7 @@ impl Vim {
|
|||
editor.newline(&editor::actions::Newline, window, cx);
|
||||
}
|
||||
editor.set_clip_at_line_ends(true, cx);
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
editor.change_selections(None, window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
let point = movement::saturating_left(map, selection.head());
|
||||
selection.collapse_to(point, SelectionGoal::None)
|
||||
|
@ -790,7 +791,7 @@ impl Vim {
|
|||
cx: &mut Context<Editor>,
|
||||
mut positions: HashMap<usize, Anchor>,
|
||||
) {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
|
||||
s.move_with(|map, selection| {
|
||||
if let Some(anchor) = positions.remove(&selection.id) {
|
||||
selection.collapse_to(anchor.to_display_point(map), SelectionGoal::None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue