commit 7a490d65c57e72342ad91e00788109d991cac6c1
parent 13a9cdc6b4d10d4e840c1b940d061a242adbef21
Author: luukvbaal <luukvbaal@gmail.com>
Date: Thu, 5 Feb 2026 15:55:11 +0100
fix(messages): increment message ID without ext_messages #37714
Problem: Message ID is not incremented without ext_messages.
Solution: Increment where callstack reaches without ext_messages.
There is no clear place marking the end of internal
messages without ext_messages so IDs are only incremented
with `nvim_echo` calls. Message IDs are currently not exposed
anywhere but the msg_show event for this to matter.
Diffstat:
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/nvim/message.c b/src/nvim/message.c
@@ -365,10 +365,10 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
// provide a new id if not given
if (id.type == kObjectTypeNil) {
- id = INTEGER_OBJ(msg_id_next);
+ id = INTEGER_OBJ(msg_id_next++);
} else if (id.type == kObjectTypeInteger) {
- id = id.data.integer > 0 ? id : INTEGER_OBJ(msg_id_next);
- msg_id_next = MAX(msg_id_next, id.data.integer);
+ id = id.data.integer > 0 ? id : INTEGER_OBJ(msg_id_next++);
+ msg_id_next = MAX(msg_id_next, id.data.integer + 1);
}
msg_ext_id = id;
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
@@ -3853,6 +3853,12 @@ describe('API', function()
{9:Error}{16:Message} |
]])
end)
+
+ it('increments message ID', function()
+ eq(1, api.nvim_echo({ { 'foo' } }, false, {}))
+ eq(4, api.nvim_echo({ { 'foo' } }, false, { id = 4 }))
+ eq(5, api.nvim_echo({ { 'foo' } }, false, {}))
+ end)
end)
describe('nvim_open_term', function()