Skip to content

Commit ff224a3

Browse files
committed
fix(pick): prevent invalid buffer when opening mini.files
1 parent dca9884 commit ff224a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lua/mini/pick.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,11 +3564,12 @@ H.set_cursor = function(win_id, lnum, col) pcall(vim.api.nvim_win_set_cursor, wi
35643564

35653565
H.set_curwin = function(win_id)
35663566
if not H.is_valid_win(win_id) then return end
3567+
35673568
-- Explicitly preserve cursor to fix Neovim<0.10 after choosing position in
35683569
-- already shown buffer
35693570
local cursor = vim.api.nvim_win_get_cursor(win_id)
3570-
vim.api.nvim_set_current_win(win_id)
3571-
H.set_cursor(win_id, cursor[1], cursor[2] + 1)
3571+
local ok, _ = pcall(vim.api.nvim_set_current_win, win_id)
3572+
if ok then H.set_cursor(win_id, cursor[1], cursor[2] + 1) end
35723573
end
35733574

35743575
H.clear_namespace = function(buf_id, ns_id) pcall(vim.api.nvim_buf_clear_namespace, buf_id, ns_id, 0, -1) end

0 commit comments

Comments
 (0)