aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_extui/cmdline.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-06-27 00:27:21 +0200
committerGitHub <noreply@github.com>2025-06-26 22:27:21 +0000
commit2b4c1127ad1c8cff38f562d71f411c35ec6ba8d6 (patch)
tree0d96ab52000df218b6b2cf396986a8caf6959b55 /runtime/lua/vim/_extui/cmdline.lua
parent6005bc68b29ea8c061183a05fcac489a54fe40c2 (diff)
downloadrneovim-2b4c1127ad1c8cff38f562d71f411c35ec6ba8d6.tar.gz
rneovim-2b4c1127ad1c8cff38f562d71f411c35ec6ba8d6.tar.bz2
rneovim-2b4c1127ad1c8cff38f562d71f411c35ec6ba8d6.zip
feat(ui): emit "msg_clear" event after clearing the screen (#34035)
Problem: ext_messages cannot tell when the screen was cleared, which is needed to clear visible messages. An empty message is also never emitted, but clears messages from the message grid. Solution: Repurpose the "msg_clear" event to be emitted when the screen was cleared. Emit an empty message with the `empty` kind to hint to a UI to clear the cmdline area.
Diffstat (limited to 'runtime/lua/vim/_extui/cmdline.lua')
-rw-r--r--runtime/lua/vim/_extui/cmdline.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/runtime/lua/vim/_extui/cmdline.lua b/runtime/lua/vim/_extui/cmdline.lua
index 53f14ccb4b..38050eb74f 100644
--- a/runtime/lua/vim/_extui/cmdline.lua
+++ b/runtime/lua/vim/_extui/cmdline.lua
@@ -56,9 +56,14 @@ end
---@param level integer
---@param hl_id integer
function M.cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
- M.level, M.indent, M.prompt = level, indent, #prompt > 0
+ M.level, M.indent, M.prompt = level, indent, M.prompt or #prompt > 0
-- Only enable TS highlighter for Ex commands (not search or filter commands).
M.highlighter.active[ext.bufs.cmd] = firstc == ':' and M.highlighter or nil
+ if ext.msg.cmd.msg_row ~= -1 then
+ ext.msg.msg_clear()
+ end
+ ext.msg.virt.last = { {}, {}, {}, {} }
+
set_text(content, ('%s%s%s'):format(firstc, prompt, (' '):rep(indent)))
if promptlen > 0 and hl_id > 0 then
api.nvim_buf_set_extmark(ext.bufs.cmd, ext.ns, 0, 0, { hl_group = hl_id, end_col = promptlen })
@@ -67,14 +72,6 @@ function M.cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
local height = math.max(ext.cmdheight, api.nvim_win_text_height(ext.wins.cmd, {}).all)
win_config(ext.wins.cmd, false, height)
M.cmdline_pos(pos)
-
- -- Clear message cmdline state; should not be shown during, and reset after cmdline.
- if ext.cfg.msg.target == 'cmd' and ext.msg.cmd.msg_row ~= -1 then
- ext.msg.prev_msg, ext.msg.dupe, ext.msg.cmd.msg_row = '', 0, -1
- api.nvim_buf_clear_namespace(ext.bufs.cmd, ext.ns, 0, -1)
- ext.msg.virt.msg = { {}, {} }
- end
- ext.msg.virt.last = { {}, {}, {}, {} }
end
--- Insert special character at cursor position.