From 541dde36e3302314e2646415dbfd2b79a6c2a1fc Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Sat, 2 Sep 2017 14:12:32 +0100 Subject: eventloop: K_EVENT should not finish operator normal_finish_command() and normal_prepare() assume that any pending operator needs to be finished after any subsequent key. Set `finish_op = false` in nv_event() to indicate that the pending operator shouldn't be finished in normal_execute(). This is how nv_visual() indicates that 'v' or 'V' in operator-pending mode should not finish the current pending operator. fixes #5398 fixes #6166 (partially; mappings are still interrupted) --- test/functional/api/vim_spec.lua | 62 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index e59b5d712d..5566c6d8e4 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -329,24 +329,80 @@ describe('api', function() } eq({ { {mode='n', blocking=false}, 13, - {mode='n', blocking=false}, -- TODO: should be blocked=true + {mode='n', blocking=false}, -- TODO: should be blocked=true ? 1 }, NIL}, meths.call_atomic(req)) eq({mode='r', blocking=true}, nvim("get_mode")) end) - -- TODO: bug #6166 it("during insert-mode map-pending, returns blocking=true #6166", function() command("inoremap xx foo") nvim("input", "ix") eq({mode='i', blocking=true}, nvim("get_mode")) end) - -- TODO: bug #6166 it("during normal-mode gU, returns blocking=false #6166", function() nvim("input", "gu") eq({mode='no', blocking=false}, nvim("get_mode")) end) end) + describe('RPC (K_EVENT) #6166', function() + it('does not complete/interrupt normal-mode operator', function() + helpers.insert([[ + FIRST LINE + SECOND LINE]]) + nvim('input', 'gg') + nvim('input', 'gu') + -- Make any non-async RPC request. + nvim('get_current_buf') + -- Buffer should not change. + helpers.expect([[ + FIRST LINE + SECOND LINE]]) + -- Now send input to complete the operator. + nvim("input", "j") + helpers.expect([[ + first line + second line]]) + end) + -- TODO: bug #6166 + pending('does not complete/interrupt normal-mode mapping', function() + command("nnoremap dd :let g:foo='it worked...'") + helpers.insert([[ + FIRST LINE + SECOND LINE]]) + nvim('input', 'gg') + nvim('input', 'd') + helpers.expect([[ + FIRST LINE + SECOND LINE]]) + -- Make any non-async RPC request. (expect() does RPC, but be explicit) + nvim('get_current_buf') + -- Send input to complete the mapping. + nvim('input', 'd') + helpers.expect([[ + FIRST LINE + SECOND LINE]]) + eq('it worked...', eval('g:foo')) + end) + it('does not complete/interrupt insert-mode mapping', function() + command("inoremap xx foo") + helpers.insert([[ + FIRST LINE + SECOND LINE]]) + nvim('input', 'ix') + helpers.expect([[ + FIRST LINE + SECOND LINxE]]) + -- Make any non-async RPC request. (expect() does RPC, but be explicit) + nvim('get_current_buf') + -- Send input to complete the mapping. + nvim('input', 'x') + helpers.expect([[ + FIRST LINE + SECOND LINxxE]]) -- TODO: should be "SECOND LINfooE" #6166 + end) + end) + describe('nvim_replace_termcodes', function() it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function() eq('\128\254X', helpers.nvim('replace_termcodes', '\128', true, true, true)) -- cgit From 3922237b1442deed48d1be32a7967e9eb6a19151 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Sep 2017 08:46:10 +0200 Subject: test: lint --- test/functional/api/vim_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 5566c6d8e4..252a380378 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -382,7 +382,7 @@ describe('api', function() helpers.expect([[ FIRST LINE SECOND LINE]]) - eq('it worked...', eval('g:foo')) + eq('it worked...', helpers.eval('g:foo')) end) it('does not complete/interrupt insert-mode mapping', function() command("inoremap xx foo") -- cgit From ce852bab04c63262ce8545c01a4ff4fc827148a1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Sep 2017 22:45:14 +0200 Subject: eventloop: K_EVENT does not finish mapping The "mapping" tests added in 541dde36e330 were flawed: - Unlike op-pending mode, RPCs are _blocked_ during map-pending. So a synchronous RPC like nvim_get_current_buf() waits until 'timeoutlen', then the mapping is canceled. - helpers.expect() also performs a blocking RPC, so again that must not intervene the two nvim_input() calls. closes #6166 --- test/functional/api/vim_spec.lua | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 252a380378..a4b643589a 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -346,37 +346,33 @@ describe('api', function() end) describe('RPC (K_EVENT) #6166', function() - it('does not complete/interrupt normal-mode operator', function() + it('does not complete ("interrupt") normal-mode operator-pending', function() helpers.insert([[ FIRST LINE SECOND LINE]]) nvim('input', 'gg') nvim('input', 'gu') - -- Make any non-async RPC request. + -- Make any RPC request (can be non-async: op-pending does not block). nvim('get_current_buf') -- Buffer should not change. helpers.expect([[ FIRST LINE SECOND LINE]]) -- Now send input to complete the operator. - nvim("input", "j") + nvim('input', 'j') helpers.expect([[ - first line - second line]]) + first line + second line]]) end) - -- TODO: bug #6166 - pending('does not complete/interrupt normal-mode mapping', function() + it('does not complete ("interrupt") normal-mode map-pending', function() command("nnoremap dd :let g:foo='it worked...'") helpers.insert([[ FIRST LINE SECOND LINE]]) nvim('input', 'gg') nvim('input', 'd') - helpers.expect([[ - FIRST LINE - SECOND LINE]]) - -- Make any non-async RPC request. (expect() does RPC, but be explicit) - nvim('get_current_buf') + -- Make any RPC request (must be async, because map-pending blocks). + nvim('get_api_info') -- Send input to complete the mapping. nvim('input', 'd') helpers.expect([[ @@ -384,22 +380,20 @@ describe('api', function() SECOND LINE]]) eq('it worked...', helpers.eval('g:foo')) end) - it('does not complete/interrupt insert-mode mapping', function() - command("inoremap xx foo") + it('does not complete ("interrupt") insert-mode map-pending', function() + command('inoremap xx foo') + command('set timeoutlen=9999') helpers.insert([[ FIRST LINE SECOND LINE]]) nvim('input', 'ix') - helpers.expect([[ - FIRST LINE - SECOND LINxE]]) - -- Make any non-async RPC request. (expect() does RPC, but be explicit) - nvim('get_current_buf') + -- Make any RPC request (must be async, because map-pending blocks). + nvim('get_api_info') -- Send input to complete the mapping. nvim('input', 'x') helpers.expect([[ FIRST LINE - SECOND LINxxE]]) -- TODO: should be "SECOND LINfooE" #6166 + SECOND LINfooE]]) end) end) -- cgit