mirror of
https://github.com/neovim/neovim.git
synced 2026-04-03 14:19:27 +00:00
fix(cmdline): redraw cmdline after empty message (#38485)
Problem: Cmdline is not redrawn after an empty message clears it. Remembered last drawn cursor position may be outdated but equal to the current cmdline content with UI2. Solution: Ensure cmdline is redrawn after an empty message clears it. Compare wanted cursor position with actual cursor position.
This commit is contained in:
@@ -121,23 +121,22 @@ function M.cmdline_special_char(c, shift)
|
||||
end)
|
||||
end
|
||||
|
||||
local curpos = { 0, 0 } -- Last drawn cursor position.
|
||||
--- Set the cmdline cursor position.
|
||||
---
|
||||
---@param pos integer
|
||||
--@param level integer
|
||||
function M.cmdline_pos(pos)
|
||||
local curpos = api.nvim_win_get_cursor(ui.wins.cmd)
|
||||
pos = #fn.strtrans(cmdbuff:sub(1, pos))
|
||||
if curpos[1] ~= M.erow + 1 or curpos[2] ~= promptlen + pos then
|
||||
curpos[1], curpos[2] = M.erow + 1, promptlen + pos
|
||||
-- Add matchparen highlighting to non-prompt part of cmdline.
|
||||
if pos > 0 and fn.exists('#matchparen#CursorMoved') == 1 then
|
||||
api.nvim_win_set_cursor(ui.wins.cmd, { curpos[1], curpos[2] - 1 })
|
||||
api.nvim_win_set_cursor(ui.wins.cmd, { M.erow + 1, promptlen + pos - 1 })
|
||||
vim._with({ win = ui.wins.cmd, wo = { eventignorewin = '' } }, function()
|
||||
api.nvim_exec_autocmds('CursorMoved', {})
|
||||
end)
|
||||
end
|
||||
api.nvim_win_set_cursor(ui.wins.cmd, curpos)
|
||||
api.nvim_win_set_cursor(ui.wins.cmd, { M.erow + 1, promptlen + pos })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -176,7 +175,7 @@ function M.cmdline_hide(level, abort)
|
||||
end
|
||||
end)
|
||||
|
||||
M.prompt, M.level, curpos[1], curpos[2] = false, 0, 0, 0
|
||||
M.prompt, M.level = false, 0
|
||||
win_config(ui.wins.cmd, true, ui.cmdheight)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user