vim: (BREAKING) clean up keymap contexts (#14233)
Release Notes: - vim: (BREAKING) Improved vim keymap contexts. Previously `vim_mode == normal` was true even when operators were pending, which led to bugs like #13789 and a requirement for custom keymaps to exclude various conditions like (`!VimObject` and `!VimWaiting`) to avoid bugs. Now `vim_mode` will be set to `operator` or `waiting` in these cases as described in [the docs](https://zed.dev/docs/vim#keybindings). For most custom keymaps this change will be a no-op or an improvement, but if you were deliberately relying on the old behaviour (if you were relying on `VimObject` or `VimWaiting` becoming true) you will need to update your keymap. --------- Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
8e853e2b56
commit
b0dbc80575
4 changed files with 186 additions and 246 deletions
|
@ -76,6 +76,7 @@ struct SelectRegister(String);
|
|||
actions!(
|
||||
vim,
|
||||
[
|
||||
ClearOperators,
|
||||
Tab,
|
||||
Enter,
|
||||
Object,
|
||||
|
@ -129,6 +130,9 @@ fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
|||
Vim::update(cx, |vim, cx| vim.push_operator(operator.clone(), cx))
|
||||
},
|
||||
);
|
||||
workspace.register_action(|_: &mut Workspace, _: &ClearOperators, cx| {
|
||||
Vim::update(cx, |vim, cx| vim.clear_operator(cx))
|
||||
});
|
||||
workspace.register_action(|_: &mut Workspace, n: &Number, cx: _| {
|
||||
Vim::update(cx, |vim, cx| vim.push_count_digit(n.0, cx));
|
||||
});
|
||||
|
@ -973,7 +977,7 @@ impl Vim {
|
|||
editor.set_cursor_shape(state.cursor_shape(), cx);
|
||||
editor.set_clip_at_line_ends(state.clip_at_line_ends(), cx);
|
||||
editor.set_collapse_matches(true);
|
||||
editor.set_input_enabled(!state.vim_controlled());
|
||||
editor.set_input_enabled(state.editor_input_enabled());
|
||||
editor.set_autoindent(state.should_autoindent());
|
||||
editor.selections.line_mode = matches!(state.mode, Mode::VisualLine);
|
||||
if editor.is_focused(cx) || editor.mouse_menu_is_focused(cx) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue