Skip to content

Commit 84d1904

Browse files
committed
fix: better handling of splitkeep for nui splits
1 parent b8e5042 commit 84d1904

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lua/noice/view/init.lua

+13-6
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ function View.get_view(view, opts)
5858
end
5959
end
6060

61+
---@type NoiceView
6162
local mod = require("noice.view.backend." .. opts.backend)
6263
local init_opts = vim.deepcopy(opts)
63-
---@type NoiceView
6464
local ret = mod(opts)
6565
if not ret:is_available() and opts.fallback then
6666
return View.get_view(opts.fallback, opts_orig)
@@ -194,12 +194,19 @@ function View:set_win_options(win)
194194
if self._opts.win_options then
195195
require("nui.utils")._.set_win_options(win, self._opts.win_options)
196196
end
197-
vim.schedule(function()
198-
vim.api.nvim_win_set_cursor(win, { 1, 0 })
199-
vim.api.nvim_win_call(win, function()
200-
vim.cmd([[noautocmd silent! normal! zt]])
197+
-- reset cursor on show
198+
vim.api.nvim_win_set_cursor(win, { 1, 0 })
199+
if self._opts.type == "split" then
200+
vim.schedule(function()
201+
-- this is needed to make the nui split behave with vim.go.splitkeep
202+
if win and vim.api.nvim_win_is_valid(win) then
203+
vim.api.nvim_win_set_cursor(win, { 1, 0 })
204+
vim.api.nvim_win_call(win, function()
205+
vim.cmd([[noautocmd silent! normal! zt]])
206+
end)
207+
end
201208
end)
202-
end)
209+
end
203210
end
204211

205212
---@param buf number buffer number

0 commit comments

Comments
 (0)