@@ -100,16 +100,32 @@ local gen_search_pat = function(pattern)
100
100
end
101
101
102
102
local process_item = function (opts , name , typ , current_dir , next_dir , bp , data , giti , msp )
103
- if opts .hidden or name :sub (1 , 1 ) ~= " ." then
104
- if typ == " directory" then
105
- local entry = current_dir .. os_sep .. name
106
- if opts .depth then
107
- table.insert (next_dir , handle_depth (bp , entry , opts .depth ))
108
- else
109
- table.insert (next_dir , entry )
110
- end
111
- if opts .add_dirs or opts .only_dirs then
112
- if not giti or giti (bp , entry .. " /" ) then
103
+ if opts .symlink or typ ~= " link" then
104
+ if opts .symlink and typ == " link" then
105
+ typ = uv .fs_stat (current_dir .. os_sep .. name ).type
106
+ end
107
+
108
+ if opts .hidden or name :sub (1 , 1 ) ~= " ." then
109
+ if typ == " directory" then
110
+ local entry = current_dir .. os_sep .. name
111
+ if opts .depth then
112
+ table.insert (next_dir , handle_depth (bp , entry , opts .depth ))
113
+ else
114
+ table.insert (next_dir , entry )
115
+ end
116
+ if opts .add_dirs or opts .only_dirs then
117
+ if not giti or giti (bp , entry .. " /" ) then
118
+ if not msp or msp (entry ) then
119
+ table.insert (data , entry )
120
+ if opts .on_insert then
121
+ opts .on_insert (entry , typ )
122
+ end
123
+ end
124
+ end
125
+ end
126
+ elseif not opts .only_dirs then
127
+ local entry = current_dir .. os_sep .. name
128
+ if not giti or giti (bp , entry ) then
113
129
if not msp or msp (entry ) then
114
130
table.insert (data , entry )
115
131
if opts .on_insert then
@@ -118,16 +134,6 @@ local process_item = function(opts, name, typ, current_dir, next_dir, bp, data,
118
134
end
119
135
end
120
136
end
121
- elseif not opts .only_dirs then
122
- local entry = current_dir .. os_sep .. name
123
- if not giti or giti (bp , entry ) then
124
- if not msp or msp (entry ) then
125
- table.insert (data , entry )
126
- if opts .on_insert then
127
- opts .on_insert (entry , typ )
128
- end
129
- end
130
- end
131
137
end
132
138
end
133
139
end
146
152
-- opts.search_pattern (regex): regex for which files will be added, string, table of strings, or fn(e) -> bool
147
153
-- opts.on_insert(entry): Will be called for each element
148
154
-- opts.silent (bool): if true will not echo messages that are not accessible
155
+ -- opts.symlink (bool): if true will follow symlinks
149
156
-- @return array with files
150
157
m .scan_dir = function (path , opts )
151
158
opts = opts or {}
0 commit comments