Skip to content
Myr

Allow fish comp to support trailing empty lines (#1284)

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

Some programs may output extra empty lines after the directive. Those lines must be ignored for fish shell completion to work. zsh and bash are not impacted. Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca> Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

authored by Marc Khouzam · committed by GitHub · parent 3ed6a39 · Browse files · 1 file+13 added−0 removed
This commit

State

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

Trailers

  • Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>

Diff stats

1 file+13 added−0 removed

  • other:+13 added−0 removed

1 file+13 added−0 removed

modified:fish_completions.go+13 added
51 unmodified lines
52 set requestComp "$args[1] %[3]s $args[2..-1] $emptyArg"53 __%[1]s_debug "Calling $requestComp"5455 set results (eval $requestComp 2> /dev/null)5657 # Some programs may output extra empty lines after the directive.58 # Let's ignore them or else it will break completion.59 # Ref: https://github.com/spf13/cobra/issues/127960 for line in $results[-1..1]61 if test (string trim -- $line) = ""62 # Found an empty line, remove it63 set results $results[1..-2]64 else65 # Found non-empty line, we have our proper output66 break67 end68 end69 set comps $results[1..-2]70 set directiveLine $results[-1]7172 # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
148 unmodified lines