Skip to content

Commit 466fbed

Browse files
fix(#2859): make sure window still exists when restoring options (#2863)
Co-authored-by: Alexander Courtis <[email protected]>
1 parent 15942df commit 466fbed

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: lua/nvim-tree/actions/node/open-file.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ local function pick_win_id()
167167

168168
if laststatus == 3 then
169169
for _, id in ipairs(not_selectable) do
170-
for opt, value in pairs(win_opts[id]) do
171-
if vim.fn.has "nvim-0.10" == 1 then
172-
vim.api.nvim_set_option_value(opt, value, { win = id })
173-
else
174-
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
170+
-- Ensure window still exists at this point
171+
if vim.api.nvim_win_is_valid(id) then
172+
for opt, value in pairs(win_opts[id]) do
173+
if vim.fn.has "nvim-0.10" == 1 then
174+
vim.api.nvim_set_option_value(opt, value, { win = id })
175+
else
176+
vim.api.nvim_win_set_option(id, opt, value) ---@diagnostic disable-line: deprecated
177+
end
175178
end
176179
end
177180
end

0 commit comments

Comments
 (0)