From fe1c1e7bb63fed658df82a3c592907fc23489144 Mon Sep 17 00:00:00 2001 From: scarlet-storm <12461256+scarlet-storm@users.noreply.github.com> Date: Thu, 26 Jun 2025 11:11:19 +0530 Subject: [PATCH 1/2] Escape singlequotes in fish_completer In case the completion string has any singlequotes, escape them before passing it to external fish command. Else the completion will fail due to unmatched quotes. eg. vim '/home --- cookbook/external_completers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/external_completers.md b/cookbook/external_completers.md index b08386f63e5..3002ba1bbfb 100644 --- a/cookbook/external_completers.md +++ b/cookbook/external_completers.md @@ -20,7 +20,7 @@ This completer will use [the fish shell](https://fishshell.com/) to handle compl ```nu let fish_completer = {|spans| - fish --command $"complete '--do-complete=($spans | str join ' ')'" + fish --command $"complete '--do-complete=($spans | str replace "'" "\\'" | str join ' ')'" | from tsv --flexible --noheaders --no-infer | rename value description | update value { From 55b26ddb0eeb4bfe869adf03e58eba5e8096302c Mon Sep 17 00:00:00 2001 From: scarlet-storm <12461256+scarlet-storm@users.noreply.github.com> Date: Thu, 26 Jun 2025 11:19:48 +0530 Subject: [PATCH 2/2] fish_completer: expand path before returning completions This fixes completions for paths which have "~". ~ expansion will no longer work after the path is enclosed in double quotes, hence expand the path before returning the completion so that subsequent completions will continue to work eg. vim ~/Doc The second completion will not work as the path will be enclosed with double quotes after first completion --- cookbook/external_completers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/external_completers.md b/cookbook/external_completers.md index 3002ba1bbfb..eb6934d9c4e 100644 --- a/cookbook/external_completers.md +++ b/cookbook/external_completers.md @@ -24,7 +24,7 @@ let fish_completer = {|spans| | from tsv --flexible --noheaders --no-infer | rename value description | update value { - if ($in | path exists) {$'"($in | str replace "\"" "\\\"" )"'} else {$in} + if ($in | path exists) {$'"($in | path expand --no-symlink | str replace --all "\"" "\\\"" )"'} else {$in} } } ```