vim gigv (#13028)
Release Notes: - vim: Fix `gi` when the insert ended at the end of a line (#12162) - vim: Add `gv` to restore previous visual selection (#12888) - vim: Fix `gl` when the first match is at the end of a line
This commit is contained in:
parent
3539a7c04a
commit
3b84b106e2
12 changed files with 239 additions and 49 deletions
|
@ -51,6 +51,7 @@ actions!(
|
|||
InsertEndOfLine,
|
||||
InsertLineAbove,
|
||||
InsertLineBelow,
|
||||
InsertAtPrevious,
|
||||
DeleteLeft,
|
||||
DeleteRight,
|
||||
ChangeToEndOfLine,
|
||||
|
@ -73,6 +74,7 @@ pub(crate) fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace
|
|||
workspace.register_action(insert_end_of_line);
|
||||
workspace.register_action(insert_line_above);
|
||||
workspace.register_action(insert_line_below);
|
||||
workspace.register_action(insert_at_previous);
|
||||
workspace.register_action(change_case);
|
||||
workspace.register_action(convert_to_upper_case);
|
||||
workspace.register_action(convert_to_lower_case);
|
||||
|
@ -341,6 +343,20 @@ fn insert_end_of_line(_: &mut Workspace, _: &InsertEndOfLine, cx: &mut ViewConte
|
|||
});
|
||||
}
|
||||
|
||||
fn insert_at_previous(_: &mut Workspace, _: &InsertAtPrevious, cx: &mut ViewContext<Workspace>) {
|
||||
Vim::update(cx, |vim, cx| {
|
||||
vim.start_recording(cx);
|
||||
vim.switch_mode(Mode::Insert, false, cx);
|
||||
vim.update_active_editor(cx, |vim, editor, cx| {
|
||||
if let Some(marks) = vim.state().marks.get("^") {
|
||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.select_anchor_ranges(marks.iter().map(|mark| *mark..*mark))
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn insert_line_above(_: &mut Workspace, _: &InsertLineAbove, cx: &mut ViewContext<Workspace>) {
|
||||
Vim::update(cx, |vim, cx| {
|
||||
vim.start_recording(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue