mirror of
https://github.com/neovim/neovim
synced 2025-07-16 17:21:49 +00:00
fix(ui): flush ext_cmdline events before doing cmdpreview #27950
Problem: Unable to update the screen for external cmdline during cmdpreview. Solution: Flush the cmdline UI before cmdpreview state.
This commit is contained in:
@ -2532,6 +2532,10 @@ static bool cmdpreview_may_show(CommandLineState *s)
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Flush now: external cmdline may itself wish to update the screen which is
|
||||
// currently disallowed during cmdpreview(no longer needed in case that changes).
|
||||
cmdline_ui_flush();
|
||||
|
||||
// Swap invalid command range if needed
|
||||
if ((ea.argt & EX_RANGE) && ea.line1 > ea.line2) {
|
||||
linenr_T lnum = ea.line1;
|
||||
|
@ -37,6 +37,9 @@ describe('vim.ui_attach', function()
|
||||
[2] = { bold = true },
|
||||
[3] = { background = Screen.colors.Grey },
|
||||
[4] = { background = Screen.colors.LightMagenta },
|
||||
[5] = { reverse = true },
|
||||
[6] = { reverse = true, bold = true },
|
||||
[7] = { background = Screen.colors.Yellow1 },
|
||||
})
|
||||
screen:attach()
|
||||
end)
|
||||
@ -188,6 +191,56 @@ describe('vim.ui_attach', function()
|
||||
feed('version<CR><CR>v<Esc>')
|
||||
n.assert_alive()
|
||||
end)
|
||||
|
||||
it("preserved 'incsearch/command' screen state after :redraw from ext_cmdline", function()
|
||||
exec_lua([[
|
||||
vim.cmd.norm('ifoobar')
|
||||
vim.cmd('1split cmdline')
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
vim.cmd.wincmd('p')
|
||||
vim.ui_attach(ns, { ext_cmdline = true }, function(event, ...)
|
||||
if event == 'cmdline_show' then
|
||||
local content = select(1, ...)
|
||||
vim.api.nvim_buf_set_lines(buf, -2, -1, false, {content[1][2]})
|
||||
vim.cmd('redraw')
|
||||
end
|
||||
return true
|
||||
end)
|
||||
]])
|
||||
-- Updates a cmdline window
|
||||
feed(':cmdline')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
cmdline |
|
||||
{5:cmdline [+] }|
|
||||
fooba^r |
|
||||
{6:[No Name] [+] }|
|
||||
|
|
||||
]],
|
||||
})
|
||||
-- Does not clear 'incsearch' highlighting
|
||||
feed('<Esc>/foo')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
foo |
|
||||
{5:cmdline [+] }|
|
||||
{5:foo}ba^r |
|
||||
{6:[No Name] [+] }|
|
||||
|
|
||||
]],
|
||||
})
|
||||
-- Shows new cmdline state during 'inccommand'
|
||||
feed('<Esc>:%s/bar/baz')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
%s/bar/baz |
|
||||
{5:cmdline [+] }|
|
||||
foo{7:ba^z} |
|
||||
{6:[No Name] [+] }|
|
||||
|
|
||||
]],
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.ui_attach', function()
|
||||
|
Reference in New Issue
Block a user