diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-03-18 16:39:57 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-03-18 16:39:57 -0400 |
commit | 5730ad937672d9bb778aee6889c2de084942f9ba (patch) | |
tree | 5cb77d6238f910ec0322df2bdf06876d9d30bdcb | |
parent | cfcc6be73e546d591ca9e9757734faf550bafcdb (diff) | |
parent | 5aa0159f013e58291e24dc391b2ae9db3badd68a (diff) | |
download | rneovim-5730ad937672d9bb778aee6889c2de084942f9ba.tar.gz rneovim-5730ad937672d9bb778aee6889c2de084942f9ba.tar.bz2 rneovim-5730ad937672d9bb778aee6889c2de084942f9ba.zip |
Merge pull request #4461 from bfredl/pum_k_event
K_EVENT should not hide the popupmenu
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | test/functional/viml/completion_spec.lua | 59 |
2 files changed, 59 insertions, 4 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 3729cd5f2d..1c33c4d549 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3084,8 +3084,10 @@ static bool ins_compl_prep(int c) /* Ignore end of Select mode mapping and mouse scroll buttons. */ if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP - || c == K_MOUSELEFT || c == K_MOUSERIGHT) + || c == K_MOUSELEFT || c == K_MOUSERIGHT || c == K_EVENT + || c == K_FOCUSGAINED || c == K_FOCUSLOST) { return retval; + } /* Set "compl_get_longest" when finding the first matches. */ if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 45dbbdb7c7..20eee24524 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -1,5 +1,6 @@ local helpers = require('test.functional.helpers') +local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq local execute, source, expect = helpers.execute, helpers.source, helpers.expect @@ -143,8 +144,60 @@ describe('completion', function() end) it('disables folding during completion', function () - execute("set foldmethod=indent") - feed('i<Tab>foo<CR><Tab>bar<Esc>ggA<C-x><C-l>') - eq(-1, eval('foldclosed(1)')) + execute("set foldmethod=indent") + feed('i<Tab>foo<CR><Tab>bar<Esc>ggA<C-x><C-l>') + eq(-1, eval('foldclosed(1)')) end) + + it('popupmenu is not interrupted by events', function () + local screen = Screen.new(40, 8) + screen:attach() + screen:set_default_attr_ignore({{bold=true, foreground=Screen.colors.Blue}}) + screen:set_default_attr_ids({ + [1] = {background = Screen.colors.LightMagenta}, + [2] = {background = Screen.colors.Grey}, + [3] = {bold = true}, + [4] = {bold = true, foreground = Screen.colors.SeaGreen}, + }) + + feed('ifoobar fooegg<cr>f<c-p>') + screen:expect([[ + foobar fooegg | + fooegg^ | + {1:foobar } | + {2:fooegg } | + ~ | + ~ | + ~ | + {3:-- }{4:match 1 of 2} | + ]]) + + eval('1 + 1') + -- popupmenu still visible + screen:expect([[ + foobar fooegg | + fooegg^ | + {1:foobar } | + {2:fooegg } | + ~ | + ~ | + ~ | + {3:-- }{4:match 1 of 2} | + ]]) + + feed('<c-p>') + -- Didn't restart completion: old matches still used + screen:expect([[ + foobar fooegg | + foobar^ | + {2:foobar } | + {1:fooegg } | + ~ | + ~ | + ~ | + {3:-- }{4:match 2 of 2} | + ]]) + end) + end) + |