fix(finder): followup to #2442, make sure entry is not nil (#2526)

This commit is contained in:
Simon Hauser
2023-05-24 14:13:50 +02:00
committed by GitHub
parent 3f1b57908b
commit 19e8a8ae8b
3 changed files with 12 additions and 4 deletions

View File

@@ -75,7 +75,9 @@ function JobFinder:_find(prompt, process_result, process_complete)
local entry local entry
if self.entry_maker then if self.entry_maker then
entry = self.entry_maker(line) entry = self.entry_maker(line)
if entry then
entry.index = line_num entry.index = line_num
end
else else
entry = line entry = line
end end
@@ -141,7 +143,9 @@ function DynamicFinder:_find(prompt, process_result, process_complete)
for _, result in ipairs(results) do for _, result in ipairs(results) do
result_num = result_num + 1 result_num = result_num + 1
local entry = self.entry_maker(result) local entry = self.entry_maker(result)
if entry then
entry.index = result_num entry.index = result_num
end
if process_result(entry) then if process_result(entry) then
return return
end end

View File

@@ -60,7 +60,9 @@ return function(opts)
for line in stdout:iter(true) do for line in stdout:iter(true) do
line_num = line_num + 1 line_num = line_num + 1
local entry = entry_maker(line) local entry = entry_maker(line)
if entry then
entry.index = line_num entry.index = line_num
end
if process_result(entry) then if process_result(entry) then
return return
end end

View File

@@ -71,7 +71,9 @@ return function(opts)
end end
local entry = entry_maker(line) local entry = entry_maker(line)
if entry then
entry.index = num_results entry.index = num_results
end
results[num_results] = entry results[num_results] = entry
process_result(entry) process_result(entry)
end end