fish_clipboard_copy: indent multiline commands

See also the earlier commits.

Closes #10437
This commit is contained in:
Johannes Altmanninger 2024-04-13 15:07:11 +02:00
parent 611a0572b1
commit a37629f869
2 changed files with 3 additions and 2 deletions

View file

@ -107,6 +107,7 @@ Interactive improvements
- Command abbreviations (those with ``--position command`` or without a ``--position``) now also expand after decorators like ``command`` (:issue:`10396`). - Command abbreviations (those with ``--position command`` or without a ``--position``) now also expand after decorators like ``command`` (:issue:`10396`).
- Abbreviations now expand after process separators like ``;`` and ``|``. This fixes a regression in version 3.6 (:issue:`9730`). - Abbreviations now expand after process separators like ``;`` and ``|``. This fixes a regression in version 3.6 (:issue:`9730`).
- When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, same as in the interactive command line editor (:issue:`8603`). - When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, same as in the interactive command line editor (:issue:`8603`).
- ``fish_clipboard_copy`` now copies indentation for multiline commands (:issue:`10437`).
New or improved bindings New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^

View file

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