fix(messages): no message kind for :write messages #31519

- Problem: cannot replace the initial bufwrite message (from `filemess`) by the final one (`"test.lua" [New] 0L, 0B written`), when using `vim.ui_attach`.
- Solution: add kind to both messages.
This commit is contained in:
Tomasz N
2024-12-10 11:39:41 +01:00
committed by GitHub
parent c87ca1e2eb
commit ca760e645b
3 changed files with 4 additions and 1 deletions

View File

@ -789,6 +789,7 @@ must handle.
kind kind
Name indicating the message kind: Name indicating the message kind:
"" (empty) Unknown (consider a |feature-request|) "" (empty) Unknown (consider a |feature-request|)
"bufwrite" |:write| message
"confirm" |confirm()| or |:confirm| dialog "confirm" |confirm()| or |:confirm| dialog
"confirm_sub" |:substitute| confirm dialog |:s_c| "confirm_sub" |:substitute| confirm dialog |:s_c|
"emsg" Error (|errors|, internal error, |:throw|, …) "emsg" Error (|errors|, internal error, |:throw|, …)

View File

@ -1148,6 +1148,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
msg_scroll = true; // don't overwrite previous file message msg_scroll = true; // don't overwrite previous file message
} }
if (!filtering) { if (!filtering) {
msg_ext_set_kind("bufwrite");
// show that we are busy // show that we are busy
#ifndef UNIX #ifndef UNIX
filemess(buf, sfname, ""); filemess(buf, sfname, "");
@ -1763,6 +1764,7 @@ restore_backup:
if (msg_add_fileformat(fileformat)) { if (msg_add_fileformat(fileformat)) {
insert_space = true; insert_space = true;
} }
msg_ext_set_kind("bufwrite");
msg_add_lines(insert_space, lnum, nchars); // add line/char count msg_add_lines(insert_space, lnum, nchars); // add line/char count
if (!shortmess(SHM_WRITE)) { if (!shortmess(SHM_WRITE)) {
if (append) { if (append) {

View File

@ -1112,7 +1112,7 @@ stack traceback:
command('write ' .. fname) command('write ' .. fname)
screen:expect({ screen:expect({
messages = { messages = {
{ content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' }, { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = 'bufwrite' },
}, },
}) })
end) end)