Skip to content

Commit c4ca28e

Browse files
committed
fix(#3143): ensure open.no_window_picker respects window_picker.exclude
1 parent 1c733e8 commit c4ca28e

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ local function usable_win_ids()
4343
end, win_ids)
4444
end
4545

46-
---Find the first window in the tab that is not NvimTree.
47-
---@return integer -1 if none available
48-
local function first_win_id()
49-
local selectable = usable_win_ids()
50-
if #selectable > 0 then
51-
return selectable[1]
52-
else
53-
return -1
54-
end
55-
end
56-
5746
---Get user to pick a window in the tab that is not NvimTree.
5847
---@return integer|nil -- If a valid window was picked, return its id. If an
5948
--- invalid window was picked / user canceled, return nil. If there are
@@ -246,9 +235,14 @@ local function get_target_winid(mode)
246235
local target_winid
247236
if not M.window_picker.enable or string.find(mode, "no_picker") then
248237
target_winid = lib.target_winid
249-
-- first available window
250-
if not vim.tbl_contains(vim.api.nvim_tabpage_list_wins(0), target_winid) then
251-
target_winid = first_win_id()
238+
local usable_wins = usable_win_ids()
239+
-- first available usable window
240+
if not vim.tbl_contains(usable_wins, target_winid) then
241+
if #usable_wins > 0 then
242+
target_winid = usable_wins[1]
243+
else
244+
target_winid = -1
245+
end
252246
end
253247
else
254248
-- pick a window

0 commit comments

Comments
 (0)