diff --git a/lua/noice/ui/cmdline.lua b/lua/noice/ui/cmdline.lua index 1c4a7c4..ffb3e79 100644 --- a/lua/noice/ui/cmdline.lua +++ b/lua/noice/ui/cmdline.lua @@ -205,8 +205,14 @@ function M.on_render(_, buf, line, byte) local cursor = byte - M.last():length() + M.last().state.pos vim.api.nvim_win_set_cursor(win, { 1, cursor }) - vim.api.nvim_win_call(win, function() - vim.cmd([[noautocmd silent! normal! ze]]) + + vim.schedule(function() + if vim.api.nvim_win_is_valid(win) then + vim.api.nvim_win_set_cursor(win, { 1, cursor }) + vim.api.nvim_win_call(win, function() + vim.cmd([[noautocmd silent! normal! ze]]) + end) + end end) local pos = vim.fn.screenpos(win, line, cmdline_start)