fix: prevent_buffer_override
- vim.schedule the buffer override autocmd to avoid being done before other ones thus failing some of the cursor movement - pcall the nvim_win_set_cursor to avoid failing when cursor is out of the window
This commit is contained in:
@@ -133,18 +133,20 @@ local goto_tbl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function M._prevent_buffer_override()
|
function M._prevent_buffer_override()
|
||||||
local curwin = a.nvim_get_current_win()
|
vim.schedule(function()
|
||||||
local curbuf = a.nvim_win_get_buf(curwin)
|
local curwin = a.nvim_get_current_win()
|
||||||
if curwin ~= M.View.winnr or curbuf == M.View.bufnr then return end
|
local curbuf = a.nvim_win_get_buf(curwin)
|
||||||
|
if curwin ~= M.View.winnr or curbuf == M.View.bufnr then return end
|
||||||
|
|
||||||
vim.cmd("buffer "..M.View.bufnr)
|
vim.cmd("buffer "..M.View.bufnr)
|
||||||
|
|
||||||
if #vim.api.nvim_list_wins() < 2 then
|
if #vim.api.nvim_list_wins() < 2 then
|
||||||
vim.cmd("vsplit")
|
vim.cmd("vsplit")
|
||||||
else
|
else
|
||||||
vim.cmd("wincmd "..goto_tbl[M.View.side])
|
vim.cmd("wincmd "..goto_tbl[M.View.side])
|
||||||
end
|
end
|
||||||
vim.cmd("buffer "..curbuf)
|
vim.cmd("buffer "..curbuf)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.win_open()
|
function M.win_open()
|
||||||
@@ -153,7 +155,7 @@ end
|
|||||||
|
|
||||||
function M.set_cursor(opts)
|
function M.set_cursor(opts)
|
||||||
if M.win_open() then
|
if M.win_open() then
|
||||||
a.nvim_win_set_cursor(M.View.winnr, opts)
|
pcall(a.nvim_win_set_cursor, M.View.winnr, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user