Skip to content

Commit

Permalink
fix: better handling of splitkeep for nui splits
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 13, 2022
1 parent b8e5042 commit 84d1904
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lua/noice/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ function View.get_view(view, opts)
end
end

---@type NoiceView
local mod = require("noice.view.backend." .. opts.backend)
local init_opts = vim.deepcopy(opts)
---@type NoiceView
local ret = mod(opts)
if not ret:is_available() and opts.fallback then
return View.get_view(opts.fallback, opts_orig)
Expand Down Expand Up @@ -194,12 +194,19 @@ function View:set_win_options(win)
if self._opts.win_options then
require("nui.utils")._.set_win_options(win, self._opts.win_options)
end
vim.schedule(function()
vim.api.nvim_win_set_cursor(win, { 1, 0 })
vim.api.nvim_win_call(win, function()
vim.cmd([[noautocmd silent! normal! zt]])
-- reset cursor on show
vim.api.nvim_win_set_cursor(win, { 1, 0 })
if self._opts.type == "split" then
vim.schedule(function()
-- this is needed to make the nui split behave with vim.go.splitkeep
if win and vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_set_cursor(win, { 1, 0 })
vim.api.nvim_win_call(win, function()
vim.cmd([[noautocmd silent! normal! zt]])
end)
end
end)
end)
end
end

---@param buf number buffer number
Expand Down

0 comments on commit 84d1904

Please sign in to comment.