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
10a3117aae
commit
9017b2c322
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue