Skip to content

Commit 9351db6

Browse files
author
Zhe Yu
committed
refactor(nvim): cleanup flatten_table_to_string
1 parent 744182d commit 9351db6

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

  • lua/vectorcode/integrations/codecompanion

lua/vectorcode/integrations/codecompanion/common.lua

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ return {
1616
if type(t) == "string" then
1717
return t
1818
end
19-
19+
2020
-- Handle empty tables or tables with empty strings
21-
local flattened = vim.iter(t):flatten(math.huge):totable()
22-
local non_empty = vim.iter(flattened):filter(function(item)
23-
return type(item) == "string" and vim.trim(item) ~= ""
24-
end):totable()
25-
26-
if #non_empty == 0 then
21+
local flattened = vim
22+
.iter(t)
23+
:flatten(math.huge)
24+
:filter(function(item)
25+
return type(item) == "string" and vim.trim(item) ~= ""
26+
end)
27+
:totable()
28+
29+
if #flattened == 0 then
2730
return "Unknown error occurred"
2831
end
29-
30-
return table.concat(non_empty, "\n")
32+
33+
return table.concat(flattened, "\n")
3134
end,
3235

3336
---@param use_lsp boolean

0 commit comments

Comments
 (0)