fix(cmdline): avoid Ex-mode NULL cmdline_block event #39043

Problem: Attempting to emit cmdline_block event with NULL cmdbuff after
<C-\><C-N> in Ex-mode.

Solution: Don't emit cmdline_block event when cmdbuff is NULL.
(cherry picked from commit f0f9620b38)
This commit is contained in:
luukvbaal
2026-04-14 14:12:24 +02:00
committed by github-actions[bot]
parent 29684ca3cc
commit 4a18c05f87
2 changed files with 5 additions and 2 deletions

View File

@@ -1011,7 +1011,8 @@ theend:
char *p = ccline.cmdbuff;
if (ui_has(kUICmdline)) {
if (exmode_active) {
// Emit cmdline_block in Ex mode unless cmdbuff is NULL (happens with <C-\><C-N> #39021).
if (exmode_active && p != NULL) {
ui_ext_cmdline_block_append(0, p);
}
ui_ext_cmdline_hide(s->gotesc);

View File

@@ -822,12 +822,14 @@ local function test_cmdline(linegrid)
cmdline = { { content = { { '' } }, firstc = ':', pos = 0 } },
cmdline_block = { { { 'echo "foo"' } } },
})
feed('vis<CR>')
-- Shouldn't crash for NULL cmdline_block event after <C-\><C-N> #39021.
feed('<C-\\><C-N>vis<CR>')
screen:expect([[
^ |
{1:~ }|*3
|
]])
assert_alive()
end)
it('works with :lua debug.debug()', function()