Skip to content
Myr

[fish] Fix parser handling of option-like args (#2208)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes error when option-like args are parsed (e.g. "-1").

authored by Andrew Zhou · committed by GitHub · parent fc7630a · Browse files · 1 file+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−5 removed

  • other:+5 added−5 removed

1 file+5 added−5 removed

modified:shell/key-bindings.fish+5 added-5 removed
125 unmodified lines
126 set fzf_query ''127 else128 set dir (__fzf_get_dir $commandline)129130 if [ "$dir" = "." -a (string sub -l 1 $commandline) != '.' ]130 if [ "$dir" = "." -a (string sub -l 1 -- $commandline) != '.' ]131 # if $dir is "." but commandline is not a relative path, this means no file path found132 set fzf_query $commandline133 else134 # Also remove trailing slash after dir, to "split" input properly135 set fzf_query (string replace -r "^$dir/?" '' "$commandline")135 set fzf_query (string replace -r "^$dir/?" -- '' "$commandline")136 end137 end138139 echo $dir
3 unmodified lines
143 function __fzf_get_dir -d 'Find the longest existing filepath from input string'144 set dir $argv145146 # Strip all trailing slashes. Ignore if $dir is root dir (/)147 if [ (string length $dir) -gt 1 ]148 set dir (string replace -r '/*$' '' $dir)147 if [ (string length -- $dir) -gt 1 ]148 set dir (string replace -r '/*$' -- '' $dir)149 end150151 # Iteratively check if dir exists and strip tail end of path152 while [ ! -d "$dir" ]153 # If path is absolute, this can keep going until ends up at /154 # If path is relative, this can keep going until entire input is consumed, dirname returns "."155 set dir (dirname "$dir")155 set dir (dirname -- "$dir")156 end157158 echo $dir159 end
2 unmodified lines