Skip to content

Commit

Permalink
string.explode as temporary workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 29, 2024
1 parent 3af5683 commit 8048164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions example/cmd/_test/cmd-clink.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
local function example_completion(word, word_index, line_state, match_builder)
args = { "example", "_carapace", "fish", "\"\"" }
for i = 2,word_index,1 do
for i = 2,word_index-1,1 do
table.insert(args, string.format("%q" ,line_state:getword(i)))
end
-- table.insert(args, word)

-- table.insert(args, string.format("%q", word))
local exploded = string.explode(line_state:getline() .. "a")
word = string.gsub(exploded[#exploded], 'a$', "")
table.insert(args, string.format("%q", word))

output = io.popen(table.concat(args, " ")):read("*a")
for line in string.gmatch(output, '[^\r\n]+') do
Expand Down
8 changes: 6 additions & 2 deletions internal/shell/cmd_clink/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import (
func Snippet(cmd *cobra.Command) string {
result := fmt.Sprintf(`local function %v_completion(word, word_index, line_state, match_builder)
args = { %#v, "_carapace", "fish", "\"\"" }
for i = 2,word_index,1 do
for i = 2,word_index-1,1 do
table.insert(args, string.format("%%q" ,line_state:getword(i)))
end
-- table.insert(args, word)
-- table.insert(args, string.format("%%q", word))
local exploded = string.explode(line_state:getline() .. "a")
word = string.gsub(exploded[#exploded], 'a$', "")
table.insert(args, string.format("%%q", word))
output = io.popen(table.concat(args, " ")):read("*a")
for line in string.gmatch(output, '[^\r\n]+') do
Expand Down

0 comments on commit 8048164

Please sign in to comment.