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:
parent
cae40b7853
commit
953fc89655
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue