diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f8c90f2ad..b2c9c592e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -33,6 +33,7 @@ Interactive improvements - :kbd:`Control-C` during command input no longer prints ``^C`` and a new prompt but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior use ``bind \cc __fish_cancel_commandline`` (:issue:`10213`). - Command-specific tab completions may now offer results whose first character is a period. For example, it is now possible to tab-complete ``git add`` for files with leading periods. The default file completions hide these files, unless the token itself has a leading period (:issue:`3707`). - The :kbd:`Control-R` history search now uses glob syntax (:issue:`10131`). +- :kbd:`Alt-E` now passes the cursor position to the external editor also if the editor aliases a supported editor (via ``complete --wraps``). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/share/functions/edit_command_buffer.fish b/share/functions/edit_command_buffer.fish index 09a8218a8..13e05005e 100644 --- a/share/functions/edit_command_buffer.fish +++ b/share/functions/edit_command_buffer.fish @@ -41,24 +41,33 @@ function edit_command_buffer --description 'Edit the command buffer in an extern end set col (math $offset + 1) - set -l basename (string match -r '[^/]*$' -- $editor[1]) - switch $basename - case vi vim nvim - set -a editor +$line +"norm! $col|" $f - case emacs emacsclient gedit kak - set -a editor +$line:$col $f - case nano - set -a editor +$line,$col $f - case joe ee - set -a editor +$line $f - case code code-oss - set -a editor --goto $f:$line:$col --wait - case subl - set -a editor $f:$line:$col --wait - case micro - set -a editor $f +$line:$col - case '*' - set -a editor $f + set -l basename (string match -r '[^/]+$' -- $editor[1]) + set -l wrap_targets (complete -- $basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1') + set -l found false + for alias in $basename $wrap_targets + switch $alias + case vi vim nvim + set -a editor +$line +"norm! $col|" $f + case emacs emacsclient gedit kak + set -a editor +$line:$col $f + case nano + set -a editor +$line,$col $f + case joe ee + set -a editor +$line $f + case code code-oss + set -a editor --goto $f:$line:$col --wait + case subl + set -a editor $f:$line:$col --wait + case micro + set -a editor $f +$line:$col + case '*' + continue + end + set found true + break + end + if not $found + set -a editor $f end __fish_disable_bracketed_paste