Try to use the fish_indent that corresponds to the fish binary
Some checks failed
Rust checks / clippy (push) Has been cancelled
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled

Users may install two versions of fish and configure their terminal to run
the one that is second in $PATH.  This is not really what I'd do but it
seems reasonable.  We should not need $PATH for this.

Fixes #10770
This commit is contained in:
Johannes Altmanninger 2024-10-10 05:12:10 +02:00
parent 88e749e4ce
commit edaf011ab1
4 changed files with 14 additions and 6 deletions

View File

@ -0,0 +1,8 @@
function __fish_indent
set -l dir "$(path dirname -- (status fish-path 2>/dev/null))"
if command -v $dir/fish_indent >/dev/null
$dir/fish_indent $argv
else
fish_indent $argv
end
end

View File

@ -18,7 +18,7 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
set -l editor (__fish_anyeditor)
or return 1
set -l indented_lines (commandline -b | fish_indent --only-indent)
set -l indented_lines (commandline -b | __fish_indent --only-indent)
string join -- \n $indented_lines >$f
set -l offset (commandline --cursor)
# compute cursor line/column
@ -91,7 +91,7 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
$editor
set -l raw_lines (command cat $f)
set -l unindented_lines (string join -- \n $raw_lines | fish_indent --only-unindent)
set -l unindented_lines (string join -- \n $raw_lines | __fish_indent --only-unindent)
# Here we're checking the exit status of the editor.
if test $status -eq 0 -a -s $f

View File

@ -3,8 +3,8 @@ function fish_clipboard_copy
if isatty stdin
# Copy the current selection, or the entire commandline if that is empty.
# Don't use `string collect -N` here - `commandline` adds a newline.
set cmdline (commandline --current-selection | fish_indent --only-indent | string collect)
test -n "$cmdline"; or set cmdline (commandline | fish_indent --only-indent | string collect)
set cmdline (commandline --current-selection | __fish_indent --only-indent | string collect)
test -n "$cmdline"; or set cmdline (commandline | __fish_indent --only-indent | string collect)
else
# Read from stdin
while read -lz line

View File

@ -47,12 +47,12 @@ function funced --description 'Edit function definition'
if test "$editor" = fish
if functions -q -- $funcname
functions --no-details -- $funcname | fish_indent --only-unindent | fish_indent --no-indent | read -z init
functions --no-details -- $funcname | __fish_indent --only-unindent | __fish_indent --no-indent | read -z init
end
set -l prompt 'printf "%s%s%s> " (set_color green) '$funcname' (set_color normal)'
if read -p $prompt -c "$init" --shell cmd
echo -n $cmd | fish_indent --only-unindent | read -lz cmd
echo -n $cmd | __fish_indent --only-unindent | read -lz cmd
eval "$cmd"
end
if set -q _flag_save