File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
lua/nvim-tree/actions/tree-modifiers Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -5,28 +5,33 @@ local Iterator = require "nvim-tree.iterators.node-iterator"
5
5
6
6
local M = {}
7
7
8
+ local function buf_match ()
9
+ local buffer_paths = vim .tbl_map (function (buffer )
10
+ return vim .api .nvim_buf_get_name (buffer )
11
+ end , vim .api .nvim_list_bufs ())
12
+
13
+ return function (path )
14
+ for _ , buffer_path in ipairs (buffer_paths ) do
15
+ local matches = utils .str_find (buffer_path , path )
16
+ if matches then
17
+ return true
18
+ end
19
+ end
20
+ return false
21
+ end
22
+ end
23
+
8
24
function M .fn (keep_buffers )
9
25
if not core .get_explorer () then
10
26
return
11
27
end
12
28
13
- local buffer_paths = vim .tbl_map (function (buffer )
14
- return vim .api .nvim_buf_get_name (buffer )
15
- end , vim .api .nvim_list_bufs ())
29
+ local matches = buf_match ()
16
30
17
31
Iterator .builder (core .get_explorer ().nodes )
18
32
:hidden ()
19
33
:applier (function (node )
20
- node .open = false
21
- if keep_buffers == true then
22
- for _ , buffer_path in ipairs (buffer_paths ) do
23
- local matches = utils .str_find (buffer_path , node .absolute_path )
24
- if matches then
25
- node .open = true
26
- return
27
- end
28
- end
29
- end
34
+ node .open = keep_buffers == true and matches (node .absolute_path )
30
35
end )
31
36
:recursor (function (n )
32
37
return n .nodes
You can’t perform that action at this time.
0 commit comments