aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/menu_spec.lua
diff options
context:
space:
mode:
authorRobin Allen <r@foon.uk>2015-07-10 23:53:19 +0100
committerJustin M. Keyes <justinkz@gmail.com>2015-07-22 10:13:49 -0400
commit5ad619a8473544ccff225d89211d5e5edee66dc9 (patch)
tree203fbe9c3581bd9987ff2a5b9c5c6a4604170ed2 /test/functional/ex_cmds/menu_spec.lua
parent8cbe5265ef22b7f320b6c0dcabd4e74b97114b0b (diff)
downloadrneovim-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 'test/functional/ex_cmds/menu_spec.lua')
-rw-r--r--test/functional/ex_cmds/menu_spec.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua
new file mode 100644
index 0000000000..6af889bf9e
--- /dev/null
+++ b/test/functional/ex_cmds/menu_spec.lua
@@ -0,0 +1,38 @@
+local helpers = require('test.functional.helpers')
+local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim
+local expect = helpers.expect
+local feed = helpers.feed
+local command = helpers.command
+
+describe(':emenu', function()
+
+ before_each(function()
+ clear()
+ execute('nnoremenu Test.Test inormal<ESC>')
+ execute('inoremenu Test.Test insert')
+ execute('vnoremenu Test.Test x')
+ end)
+
+ it('executes correct bindings in normal mode without using API', function()
+ execute('emenu Test.Test')
+ expect('normal')
+ end)
+
+ it('executes correct bindings in normal mode', function()
+ command('emenu Test.Test')
+ expect('normal')
+ end)
+
+ it('executes correct bindings in insert mode', function()
+ feed('i')
+ command('emenu Test.Test')
+ expect('insert')
+ end)
+
+ it('executes correct bindings in visual mode', function()
+ feed('iabcde<ESC>0lvll')
+ command('emenu Test.Test')
+ expect('ae')
+ end)
+
+end)