aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_extui/cmdline.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-05-02 19:46:30 +0200
committerGitHub <noreply@github.com>2025-05-02 19:46:30 +0200
commit39a5b7f239fb74eae06adbe3995d6bd2c4e230e2 (patch)
treec0c18cda2e270d8142d02f63bd44cb278b84e07e /runtime/lua/vim/_extui/cmdline.lua
parentc916bdf3298608d26ec6f68dd7eb0f830e7b7909 (diff)
downloadrneovim-39a5b7f239fb74eae06adbe3995d6bd2c4e230e2.tar.gz
rneovim-39a5b7f239fb74eae06adbe3995d6bd2c4e230e2.tar.bz2
rneovim-39a5b7f239fb74eae06adbe3995d6bd2c4e230e2.zip
fix(extui): cmdline visibility, cmdheight cursor position (#33774)
Problem: The cmdline popupmenu is hidden behind extui windows. 'showmode' message is drawn over the cmdline. Changing the 'cmdheight' to accommodate space for the text in the cmdline may change the current cursor position. Solution: Ensure kZIndexMessages < zindex < kZIndexCmdlinePopupMenu. Clear the 'showmode' message when the cmdline level is negative. Temporarily set 'splitkeep' = "screen" when changing the 'cmdheight'.
Diffstat (limited to 'runtime/lua/vim/_extui/cmdline.lua')
-rw-r--r--runtime/lua/vim/_extui/cmdline.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/lua/vim/_extui/cmdline.lua b/runtime/lua/vim/_extui/cmdline.lua
index 2210ecd8ba..970d62c059 100644
--- a/runtime/lua/vim/_extui/cmdline.lua
+++ b/runtime/lua/vim/_extui/cmdline.lua
@@ -6,6 +6,7 @@ local M = {
indent = 0, -- Current indent for block event.
prompt = false, -- Whether a prompt is active; messages are placed in the 'prompt' window.
row = 0, -- Current row in the cmdline buffer, > 0 for block events.
+ level = -1, -- Current cmdline level, < 0 when inactive (otherwise unused).
}
--- Set the 'cmdheight' and cmdline window height. Reposition message windows.
@@ -20,7 +21,11 @@ local function win_config(win, hide, height)
api.nvim_win_set_height(win, height)
end
if vim.o.cmdheight ~= height then
- vim.cmd('noautocmd set cmdheight=' .. height)
+ -- Avoid moving the cursor with 'splitkeep' = "screen", and altering the user
+ -- configured value with noautocmd.
+ vim._with({ noautocmd = true, o = { splitkeep = 'screen' } }, function()
+ vim.o.cmdheight = height
+ end)
ext.msg.set_pos()
end
end
@@ -47,10 +52,10 @@ end
---@param firstc string
---@param prompt string
---@param indent integer
---@param level integer
+---@param level integer
---@param hl_id integer
-function M.cmdline_show(content, pos, firstc, prompt, indent, _, hl_id)
- M.indent, M.prompt = indent, #prompt > 0
+function M.cmdline_show(content, pos, firstc, prompt, indent, level, hl_id)
+ M.level, M.indent, M.prompt = level, indent, #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
set_text(content, ('%s%s%s'):format(firstc, prompt, (' '):rep(indent)))
@@ -127,7 +132,7 @@ function M.cmdline_hide(_, abort)
end)
end
- M.prompt, curpos[1], curpos[2] = false, 0, 0
+ M.prompt, M.level, curpos[1], curpos[2] = false, -1, 0, 0
win_config(ext.wins[ext.tab].cmd, true, ext.cmdheight)
end