From 2f0a42701b4aa65b55fff8f32878d9adc7e7ac77 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 12 Mar 2023 18:22:29 +0100 Subject: [PATCH] fix(cmdline): make sure cursor is always visible --- lua/noice/ui/cmdline.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)