From a37629f869f3e7715c96633ce0eed7e5a83b4742 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 13 Apr 2024 15:07:11 +0200 Subject: [PATCH] fish_clipboard_copy: indent multiline commands See also the earlier commits. Closes #10437 --- CHANGELOG.rst | 1 + share/functions/fish_clipboard_copy.fish | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2b33c6df5..954f3ef53 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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`). - 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`). +- ``fish_clipboard_copy`` now copies indentation for multiline commands (:issue:`10437`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/share/functions/fish_clipboard_copy.fish b/share/functions/fish_clipboard_copy.fish index 0cf5f15a0..adfc2f54d 100644 --- a/share/functions/fish_clipboard_copy.fish +++ b/share/functions/fish_clipboard_copy.fish @@ -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 | string collect) - test -n "$cmdline"; or set cmdline (commandline | 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