Skip to content

Commit 2044cf3

Browse files
committed
fix(file): handle max results without Job:shutdown in filter, fixes #157
1 parent 9b64591 commit 2044cf3

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lua/neo-tree/sources/filesystem/lib/filter_external.lua

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,33 @@ M.find_files = function(opts)
124124
if fd_supports_max_results then
125125
maximum_results = nil
126126
end
127+
local item_count = 0
128+
local over_limit = false
127129
Job
128130
:new({
129131
command = cmd,
130132
cwd = path,
131133
args = args,
132134
enable_recording = false,
133-
maximum_results = maximum_results,
134135
on_stdout = function(err, line)
135-
if opts.on_insert then
136-
opts.on_insert(err, line)
136+
if not over_limit then
137+
if opts.on_insert then
138+
opts.on_insert(err, line)
139+
end
140+
item_count = item_count + 1
141+
over_limit = maximum_results and item_count > maximum_results
137142
end
138143
end,
139144
on_stderr = function(err, line)
140-
if opts.on_insert then
141-
if not err then
142-
err = line
145+
if not over_limit then
146+
if opts.on_insert then
147+
if not err then
148+
err = line
149+
end
150+
opts.on_insert(err, line)
143151
end
144-
opts.on_insert(err, line)
152+
item_count = item_count + 1
153+
over_limit = maximum_results and item_count > maximum_results
145154
end
146155
end,
147156
on_exit = function(_, return_val)

0 commit comments

Comments
 (0)