File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed
lua/nvim-tree/actions/node Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -1523,7 +1523,8 @@ Configuration options for opening a file from nvim-tree.
1523
1523
1524
1524
*nvim-tree.actions.open_file.window_picker.enable*
1525
1525
Enable the feature. If the feature is not enabled, files will open in
1526
- window from which you last opened the tree.
1526
+ window from which you last opened the tree, obeying
1527
+ | nvim-tree.actions.open_file.window_picker.exclude |
1527
1528
Type: `boolean ` , Default: `true`
1528
1529
1529
1530
*nvim-tree.actions.open_file.window_picker.picker*
@@ -1542,9 +1543,10 @@ Configuration options for opening a file from nvim-tree.
1542
1543
Type: `string ` , Default: `" ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" `
1543
1544
1544
1545
*nvim-tree.actions.open_file.window_picker.exclude*
1545
- Table of buffer option names mapped to a list of option values that
1546
- indicates to the picker that the buffer's window should not be
1547
- selectable.
1546
+ Table of buffer option names mapped to a list of option values.
1547
+ Windows containing matching buffers will not be:
1548
+ - available when using a window picker
1549
+ - selected when not using a window picker
1548
1550
Type: `table` , Default: >lua
1549
1551
{
1550
1552
filetype = {
Original file line number Diff line number Diff line change @@ -43,17 +43,6 @@ local function usable_win_ids()
43
43
end , win_ids )
44
44
end
45
45
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
-
57
46
--- Get user to pick a window in the tab that is not NvimTree.
58
47
--- @return integer | nil -- If a valid window was picked , return its id. If an
59
48
--- invalid window was picked / user canceled, return nil. If there are
@@ -246,9 +235,14 @@ local function get_target_winid(mode)
246
235
local target_winid
247
236
if not M .window_picker .enable or string.find (mode , " no_picker" ) then
248
237
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
252
246
end
253
247
else
254
248
-- pick a window
You can’t perform that action at this time.
0 commit comments