diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2025-01-22 23:13:40 +0100 |
---|---|---|
committer | luukvbaal <luukvbaal@gmail.com> | 2025-01-24 11:39:39 +0100 |
commit | d98827b634af29d74079d1848dd5e8c5d2be1233 (patch) | |
tree | d9f53ce1424d5cdb722d9dec322181753eaf95e1 | |
parent | 0fd4ef5da7448fa3449643b23d6aa3af1640efe8 (diff) | |
download | rneovim-d98827b634af29d74079d1848dd5e8c5d2be1233.tar.gz rneovim-d98827b634af29d74079d1848dd5e8c5d2be1233.tar.bz2 rneovim-d98827b634af29d74079d1848dd5e8c5d2be1233.zip |
fix(messages): avoid empty msg_showmode with 'noshowmode'
-rw-r--r-- | src/nvim/message.c | 6 | ||||
-rw-r--r-- | test/functional/lua/ui_event_spec.lua | 63 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 22 |
3 files changed, 55 insertions, 36 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 4c20edb7eb..6fc102e4ff 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3183,7 +3183,11 @@ void msg_ext_flush_showmode(void) { // Showmode messages doesn't interrupt normal message flow, so we use // separate event. Still reuse the same chunking logic, for simplicity. - if (ui_has(kUIMessages)) { + // This is called unconditionally; check if we are emitting, or have + // emitted non-empty "content". + static bool clear = false; + if (ui_has(kUIMessages) && (msg_ext_last_attr != -1 || clear)) { + clear = msg_ext_last_attr != -1; msg_ext_emit_chunk(); Array *tofree = msg_ext_init_chunks(); ui_call_msg_showmode(*tofree); diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index c6f98c8640..8bfd574fb9 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -345,31 +345,36 @@ describe('vim.ui_attach', function() vim.api.nvim_buf_set_lines(0, -2, -1, false, { err[1] }) end) ]]) + local s1 = [[ + ^ | + {1:~ }|*4 + ]] + screen:expect(s1) + feed('QQQQQQ<CR>') screen:expect({ grid = [[ - ^ | - {1:~ }|*4 - ]], - }) - feed('ifoo') - screen:expect({ - grid = [[ - foo^ | - {1:~ }|*4 - ]], - showmode = { { '-- INSERT --', 5, 11 } }, - }) - feed('<esc>:1mes clear<cr>:mes<cr>') - screen:expect({ - grid = [[ - foo | - {3: }| - {9:Excessive errors in vim.ui_attach() call}| - {9:back from ns: 1.} | + {9:obal 'err' (a nil value)} | + {9:stack traceback:} | + {9: [string "<nvim>"]:2: in function}| + {9: <[string "<nvim>"]:1>} | {100:Press ENTER or type command to continue}^ | ]], - cmdline = { { abort = false } }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 100, 18 } }, + history = true, + kind = 'return_prompt', + }, + }, }) + feed(':1mes clear<CR>:mes<CR>') + screen:expect([[ + | + {3: }| + {9:Excessive errors in vim.ui_attach() call}| + {9:back from ns: 1.} | + {100:Press ENTER or type command to continue}^ | + ]]) feed('<cr>') -- Also when scheduled exec_lua([[ @@ -378,7 +383,7 @@ describe('vim.ui_attach', function() end) ]]) screen:expect({ - any = 'fo^o', + grid = s1, messages = { { content = { @@ -410,14 +415,12 @@ describe('vim.ui_attach', function() }, }) feed('<esc>:1mes clear<cr>:mes<cr>') - screen:expect({ - grid = [[ - foo | - {3: }| - {9:Excessive errors in vim.ui_attach() call}| - {9:back from ns: 2.} | - {100:Press ENTER or type command to continue}^ | - ]], - }) + screen:expect([[ + | + {3: }| + {9:Excessive errors in vim.ui_attach() call}| + {9:back from ns: 2.} | + {100:Press ENTER or type command to continue}^ | + ]]) end) end) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index b70bd0e808..4038e596fa 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1391,13 +1391,25 @@ stack traceback: screen_showmode(...) showmode = showmode + 1 end + local s1 = [[ + ^ | + {1:~ }|*4 + ]] + screen:expect(s1) + eq(showmode, 0) + feed('i') screen:expect({ - grid = [[ - ^ | - {1:~ }|*4 - ]], + grid = s1, + showmode = { { '-- INSERT --', 5, 11 } }, }) - eq(showmode, 1) + eq(showmode, 2) + command('set noshowmode') + feed('<Esc>') + screen:expect(s1) + eq(showmode, 3) + feed('i') + screen:expect_unchanged() + eq(showmode, 3) end) it('emits single message for multiline print())', function() |