andreyorst / fzf.kak

FZF for Kakoune
MIT License
143 stars 33 forks source link

Grep with skim fails to jump to lines with special characters #61

Closed krobelus closed 5 years ago

krobelus commented 5 years ago

Steps to reproduce

  1. Create file minimal_kakrc

    source "%val{config}/plugins/plug.kak/rc/plug.kak"
    plug "andreyorst/fzf.kak" tag "v1.0.1"
    # foo  %{
  2. Start kak and enter fuzzy grep mode.

kak -n minimal_kakrc -e 'source minimal_kakrc; fzf-mode; execute-keys g'

  1. Search for foo and press Return.

What should happen

The cursor should jump to and select line 3.

What happens instead

It doesn't, and there's an error message in the debug buffer:

error running command 'evaluate-commands -client client0  %{fzf-sk-grep-handler %{minimal_kakrc:3:# foo  %{}}
evaluate-commands -client client0 %{buffer %opt{fzf_sk_first_file}}
': parse error: 0:36: unterminated string '%{...}'

Environment information

Kakoune version: Kakoune v2019.01.20 fzf.kak v1.0.1 (I believe master has the same issue)

andreyorst commented 5 years ago

I've pushed the fix, but given that you're using tag "v1.0.1" I assume that you're using stable kakoune release, so here's the patch that you can apply manually, I guess..

diff --git a/rc/fzf.kak b/rc/fzf.kak
index 70cde2c..899e7bb 100644
--- a/rc/fzf.kak
+++ b/rc/fzf.kak
@@ -225,7 +225,8 @@ fzf -params .. %{ evaluate-commands %sh{
                         *)                             item=${line} ;;
                     esac
                     if [ -n "${item}" ]; then
-                        printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}"
+                        item=$(printf "%s\n" "${item}" | sed "s/@/@@/g")
+                        printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %&${kakoune_cmd} %@${item}@&"
                         break
                     fi
                 done
krobelus commented 5 years ago

Great! I couldn't spot the source of the problem right away so thanks for fixing it so quickly :)