Skip to content

Commit a1edc4b

Browse files
schnittchenpynappo
authored andcommitted
fix(netrw): skip hijack for stale dir_window
1 parent ff84e6e commit a1edc4b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/neo-tree/setup/netrw.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ M.hijack = function()
3939
utils.debounce("hijack_netrw_" .. dir_window, function()
4040
local manager = require("neo-tree.sources.manager")
4141
local log = require("neo-tree.log")
42+
-- The hijack may have been triggered by a BufEnter that fired in a transient
43+
-- window that no longer exists (this can happen during `:e <dir>` when the
44+
-- startup buffer is a directory). Skip in that case so we don't create an
45+
-- orphan state for a dead window.
46+
if not vim.api.nvim_win_is_valid(dir_window) then
47+
log.debug("hijack_netrw: dir_window", dir_window, "is no longer valid, skipping")
48+
return
49+
end
4250
-- We will want to replace the "directory" buffer with either the "alternate"
4351
-- buffer or a new blank one.
4452
local replacement_buffer = vim.fn.bufnr("#")

0 commit comments

Comments
 (0)