perf: return a table of results from the command finder

When reading the output of a command we are now reading the stream line
by line and building the table of results. This will save us a loop of
the results later, if we returned a string we need to split the string
before adding each line to the completion buffer because nvim only
supports replacing one line at a time.
This commit is contained in:
Ade Attwood 2023-04-25 20:21:10 +01:00
parent cae40b7853
commit 953fc89655

View file

@ -37,10 +37,14 @@ utils.command_finder = function(command, min)
if handle == nil then if handle == nil then
return {} return {}
end end
local result = handle:read "*a"
handle:close()
return result local results = {};
for line in handle:lines() do
table.insert(results, { content = line })
end
handle:close()
return results
end end
end end