diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-06-26 10:47:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 10:47:18 +0200 |
commit | 8b263c7a6868105adae69f001899c5837b302bef (patch) | |
tree | 6c042cffb967fdf690fe76f23a6ed0ad05077f58 | |
parent | 48b4ecc96d505a8e5885a8a3cf3a59dc75c250a9 (diff) | |
parent | 4bf05ba3997b8033ccfd76503cd1fe14a9557a0f (diff) | |
download | rneovim-8b263c7a6868105adae69f001899c5837b302bef.tar.gz rneovim-8b263c7a6868105adae69f001899c5837b302bef.tar.bz2 rneovim-8b263c7a6868105adae69f001899c5837b302bef.zip |
Merge pull request #10344 from bfredl/extcmdredraw
cmdline: remove invalid cmdline_show event when aborting mapping
-rw-r--r-- | src/nvim/ex_getln.c | 1 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 39 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 8 |
3 files changed, 43 insertions, 5 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 479d195966..1c1bfcad31 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1978,6 +1978,7 @@ static int command_line_changed(CommandLineState *s) static void abandon_cmdline(void) { XFREE_CLEAR(ccline.cmdbuff); + ccline.redraw_state = kCmdRedrawNone; if (msg_scrolled == 0) { compute_cmdrow(); } diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 915e7ae867..c63b726308 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -761,8 +761,42 @@ local function test_cmdline(linegrid) }}, wildmenu_items=expected, wildmenu_pos=0} end) + it("doesn't send invalid events when aborting mapping #10000", function() + command('cnoremap ab c') + + feed(':xa') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + content = { { "x" } }, + firstc = ":", + pos = 1, + special = { "a", false } + }}} + + -- This used to send an invalid event where pos where larger than the total + -- lenght of content. Checked in _handle_cmdline_show. + feed('<esc>') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) + end +-- the representation of cmdline and cmdline_block contents changed with ext_linegrid +-- (which uses indexed highlights) so make sure to test both +describe('ui/ext_cmdline', function() test_cmdline(true) end) +describe('ui/ext_cmdline (legacy highlights)', function() test_cmdline(false) end) + describe('cmdline redraw', function() local screen before_each(function() @@ -813,8 +847,3 @@ describe('cmdline redraw', function() ]], unchanged=true} end) end) - --- the representation of cmdline and cmdline_block contents changed with ext_linegrid --- (which uses indexed highlights) so make sure to test both -describe('ui/ext_cmdline', function() test_cmdline(true) end) -describe('ui/ext_cmdline (legacy highlights)', function() test_cmdline(false) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 044e4cc39c..0367e85028 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -946,6 +946,14 @@ function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level if firstc == '' then firstc = nil end if prompt == '' then prompt = nil end if indent == 0 then indent = nil end + + -- check position is valid #10000 + local len = 0 + for _, chunk in ipairs(content) do + len = len + string.len(chunk[2]) + end + assert(pos <= len) + self.cmdline[level] = {content=content, pos=pos, firstc=firstc, prompt=prompt, indent=indent} end |