aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotomo <notomo.motono@gmail.com>2022-11-07 10:20:27 +0900
committernotomo <notomo.motono@gmail.com>2022-11-07 10:20:27 +0900
commit72f8613e97e3ab4e375a1b9dd20c847f7148acf2 (patch)
tree417579d4693b0d5937633d7a32233f442e96cdc3
parent8045296e8b6d10611a5fce2db0b9b90a1989100c (diff)
downloadrneovim-72f8613e97e3ab4e375a1b9dd20c847f7148acf2.tar.gz
rneovim-72f8613e97e3ab4e375a1b9dd20c847f7148acf2.tar.bz2
rneovim-72f8613e97e3ab4e375a1b9dd20c847f7148acf2.zip
fix(ui-ext): correct message kind in history before vim.ui_attach()
-rw-r--r--src/nvim/message.c1
-rw-r--r--test/functional/lua/ui_event_spec.lua27
2 files changed, 28 insertions, 0 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index fa1c8036e6..e42fd42d46 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3151,6 +3151,7 @@ int msg_end(void)
void msg_ext_ui_flush(void)
{
if (!ui_has(kUIMessages)) {
+ msg_ext_kind = NULL;
return;
}
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua
index 57ffcf7b4e..6481da900e 100644
--- a/test/functional/lua/ui_event_spec.lua
+++ b/test/functional/lua/ui_event_spec.lua
@@ -117,4 +117,31 @@ describe('vim.ui_attach', function()
})
eq(0, helpers.eval('v:shell_error'))
end)
+
+ it('can receive accurate message kinds even if they are history', function()
+ exec_lua([[
+ vim.cmd.echomsg("'message1'")
+ print('message2')
+ vim.ui_attach(ns, { ext_messages = true }, on_event)
+ vim.cmd.echomsg("'message3'")
+ ]])
+ feed(':messages<cr>')
+ feed('<cr>')
+
+ local actual = exec_lua([[
+ return vim.tbl_filter(function (event)
+ return event[1] == "msg_history_show"
+ end, events)
+ ]])
+ eq({
+ {
+ 'msg_history_show',
+ {
+ { 'echomsg', { { 0, 'message1' } } },
+ { '', { { 0, 'message2' } } },
+ { 'echomsg', { { 0, 'message3' } } },
+ },
+ },
+ }, actual, inspect(actual))
+ end)
end)