chrisant996 / clink-fzf

Fzf integration for Clink
MIT License
77 stars 10 forks source link

inserting multiple files by fzf_file() #20

Closed gotoh closed 2 months ago

gotoh commented 2 months ago

The help document of fzf_file() says "choose one or multiple to insert them", but in reality it only inserts one. Changing r:read("*line") to r:read("*all") will insert the multiple selected items, but the entire items gets quoted as if one space-containd item is inserted.

Is this the intended behavior? I'd like it to be possible to expand multiple items. It would be good if each individual item was quoted as needed.

I'm use this tiny fix, but it is not good when space-contained item is selected.

> diff -u fzf-orig.lua fzf.lua
--- fzf-orig.lua        2024-07-05 21:39:05.194089200 +0900
+++ fzf.lua     2024-07-05 21:26:33.596039100 +0900
@@ -648,13 +648,13 @@
         return
     end

-    local str = r:read('*line')
+    local str = r:read('*all')
     str = str and str:gsub('[\r\n]+', ' ') or ''
     str = str:gsub(' +$', '')
     r:close()

     if #str > 0 then
-        insert_match(rl_buffer, first, last, has_quote, str)
+       insert_match(rl_buffer, first, last, '', str)
     end

     rl_buffer:refreshline()
@@ -1182,3 +1182,4 @@
     -- Reset the fzf completion hook.
     fzf_complete_intercept = false
 end)
chrisant996 commented 2 months ago

Thanks for reporting this. It's not the intended behavior.