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 10a3117aae
commit 9017b2c322

View file

@ -37,10 +37,14 @@ utils.command_finder = function(command, min)
if handle == nil then
return {}
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