From bfe1bc0a3de1f11d362acd67e476c7167f5558c7 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Sat, 3 Apr 2021 13:02:39 +0300 Subject: [PATCH] fix #87 --- rc/fzf.kak | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index 21ab66d..60ba15b 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -138,10 +138,13 @@ Switches: fzf -params .. %{ evaluate-commands %sh{ fzf_impl="${kak_opt_fzf_implementation:?}" + # trims selection and escapes single quotes + selection=$(printf "%s" "${kak_selection:-}" | sed -e "s/^[[:blank:]]*//g;s/[[:blank:]]*$//g;s/'/'\\\\''/g") + [ "${kak_opt_fzf_use_main_selection:-}" = "true" ] && \ - [ "$(printf "%s" "${kak_selection:-}" | wc -m)" -gt 1 ] && \ - [ "$(printf "%s" "${kak_selection:-}" | wc -l)" -eq 1 ] && \ - default_query="-i -q ${kak_selection:-}" + [ "$(printf "%s" "$kak_selection" | wc -m)" -gt 1 ] && \ + [ "$(printf "%s\n" "$selection" | wc -l)" -eq 1 ] && \ + default_query="-i -q '$selection'" while [ $# -gt 0 ]; do case $1 in