diff options
| author | luukvbaal <luukvbaal@gmail.com> | 2025-05-04 22:02:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 20:02:02 +0000 |
| commit | d4ecfc4234957f80d1a866654cfc308bd98e1bf1 (patch) | |
| tree | f646783e3fe5f5199a63faa03112906769809aa7 /runtime/lua/vim/_extui/messages.lua | |
| parent | ba2a5a7787b0b26ce3cbe70e31e112f2d15fb35b (diff) | |
fix(extui): message may overwrite active cmdline #33846
Problem: Active cmdline may be overwritten by a message.
Solution: Check if cmdline is active before writing message.
Diffstat (limited to 'runtime/lua/vim/_extui/messages.lua')
| -rw-r--r-- | runtime/lua/vim/_extui/messages.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/lua/vim/_extui/messages.lua b/runtime/lua/vim/_extui/messages.lua index ea44da76b0..d6a4ebff84 100644 --- a/runtime/lua/vim/_extui/messages.lua +++ b/runtime/lua/vim/_extui/messages.lua @@ -312,15 +312,19 @@ function M.msg_show(kind, content) M.set_pos('prompt') else local tar = ext.cfg.msg.pos - M.virt.last[M.virt.idx.search][1] = tar ~= 'cmd' and M.virt.last[M.virt.idx.search][1] or nil + if tar == 'cmd' then + if ext.cmd.level > 0 then + return -- Do not overwrite an active cmdline. + end + -- Store the time when an error message was emitted in order to not overwrite + -- it with 'last' virt_text in the cmdline to give the user a chance to read it. + M.cmd.last_emsg = kind == 'emsg' and os.time() or M.cmd.last_emsg + M.virt.last[M.virt.idx.search][1] = nil + end + M.show_msg(tar, content, replace_bufwrite, kind == 'list_cmd') -- Replace message for every second bufwrite message. replace_bufwrite = not replace_bufwrite and kind == 'bufwrite' - -- Store the time when an error message was emitted in order to not overwrite - -- it with 'last' virt_text in the cmdline to give the user a chance to read it. - if tar == 'cmd' and kind == 'emsg' then - M.cmd.last_emsg = os.time() - end end end @@ -330,7 +334,7 @@ function M.msg_clear() end --- ---@param content MsgContent function M.msg_showmode(content) - M.virt.last[M.virt.idx.mode] = ext.cmd.level < 0 and content or {} + M.virt.last[M.virt.idx.mode] = ext.cmd.level > 0 and {} or content M.virt.last[M.virt.idx.search] = {} set_virttext('last') end |
