Merge pull request #4461 from bfredl/pum_k_event

K_EVENT should not hide the popupmenu
This commit is contained in:
Justin M. Keyes 2016-03-18 16:39:57 -04:00
commit 5730ad9376
2 changed files with 59 additions and 4 deletions

View File

@ -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

View File

@ -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)