diff options
author | Robin Allen <r@foon.uk> | 2015-07-10 23:53:19 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-07-22 10:13:49 -0400 |
commit | 5ad619a8473544ccff225d89211d5e5edee66dc9 (patch) | |
tree | 203fbe9c3581bd9987ff2a5b9c5c6a4604170ed2 /src | |
parent | 8cbe5265ef22b7f320b6c0dcabd4e74b97114b0b (diff) | |
download | rneovim-5ad619a8473544ccff225d89211d5e5edee66dc9.tar.gz rneovim-5ad619a8473544ccff225d89211d5e5edee66dc9.tar.bz2 rneovim-5ad619a8473544ccff225d89211d5e5edee66dc9.zip |
menu: Fix :emenu mode detection #2992
A menu item can have separate bindings for each Vim mode.
:emenu checks to see which binding it should execute. But, it assumes
it can only be called from Normal mode, so its mode detection is based
on some guesswork. For instance, it detects if you've just used C-O
and, if so, uses the Insert mode binding.
Now that :emenu can be called from any mode (via vim_command), this
commit has it check the actual mode we're in, and simply use the
binding for that mode if we aren't in Normal mode.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/menu.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c index a8bf4ee5be..d965de6019 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1257,11 +1257,15 @@ void ex_emenu(exarg_T *eap) /* Found the menu, so execute. * Use the Insert mode entry when returning to Insert mode. */ - if (restart_edit - && !current_SID - ) { + if (((State & INSERT) || restart_edit) && !current_SID) { mode = (char_u *)"Insert"; idx = MENU_INDEX_INSERT; + } else if (get_real_state() & VISUAL) { + /* Detect real visual mode -- if we are really in visual mode we + * don't need to do any guesswork to figure out what the selection + * is. Just execute the visual binding for the menu. */ + mode = (char_u *)"Visual"; + idx = MENU_INDEX_VISUAL; } else if (eap->addr_count) { pos_T tpos; |