mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #10344 from bfredl/extcmdredraw
cmdline: remove invalid cmdline_show event when aborting mapping
This commit is contained in:
@@ -1978,6 +1978,7 @@ static int command_line_changed(CommandLineState *s)
|
|||||||
static void abandon_cmdline(void)
|
static void abandon_cmdline(void)
|
||||||
{
|
{
|
||||||
XFREE_CLEAR(ccline.cmdbuff);
|
XFREE_CLEAR(ccline.cmdbuff);
|
||||||
|
ccline.redraw_state = kCmdRedrawNone;
|
||||||
if (msg_scrolled == 0) {
|
if (msg_scrolled == 0) {
|
||||||
compute_cmdrow();
|
compute_cmdrow();
|
||||||
}
|
}
|
||||||
|
@@ -761,8 +761,42 @@ local function test_cmdline(linegrid)
|
|||||||
}}, wildmenu_items=expected, wildmenu_pos=0}
|
}}, wildmenu_items=expected, wildmenu_pos=0}
|
||||||
end)
|
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
|
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()
|
describe('cmdline redraw', function()
|
||||||
local screen
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@@ -813,8 +847,3 @@ describe('cmdline redraw', function()
|
|||||||
]], unchanged=true}
|
]], unchanged=true}
|
||||||
end)
|
end)
|
||||||
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)
|
|
||||||
|
@@ -946,6 +946,14 @@ function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level
|
|||||||
if firstc == '' then firstc = nil end
|
if firstc == '' then firstc = nil end
|
||||||
if prompt == '' then prompt = nil end
|
if prompt == '' then prompt = nil end
|
||||||
if indent == 0 then indent = 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,
|
self.cmdline[level] = {content=content, pos=pos, firstc=firstc,
|
||||||
prompt=prompt, indent=indent}
|
prompt=prompt, indent=indent}
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user