mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 18:21:16 -03:00
edit_command_buffer: if aliasee is a recognized editor, pass cursor position too
If I alias "e" to "emacsclient" it will probably accept the same options. Let's dereference the alias so we can detect support for passing the cursor position in more cases. This does not solve the problem for recursive cases (e.g. alias of another alias). If we want to handle that we would need cycle detection.
This commit is contained in:
@@ -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`).
|
- :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`).
|
- 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`).
|
- 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
|
New or improved bindings
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@@ -41,24 +41,33 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
|
|||||||
end
|
end
|
||||||
set col (math $offset + 1)
|
set col (math $offset + 1)
|
||||||
|
|
||||||
set -l basename (string match -r '[^/]*$' -- $editor[1])
|
set -l basename (string match -r '[^/]+$' -- $editor[1])
|
||||||
switch $basename
|
set -l wrap_targets (complete -- $basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1')
|
||||||
case vi vim nvim
|
set -l found false
|
||||||
set -a editor +$line +"norm! $col|" $f
|
for alias in $basename $wrap_targets
|
||||||
case emacs emacsclient gedit kak
|
switch $alias
|
||||||
set -a editor +$line:$col $f
|
case vi vim nvim
|
||||||
case nano
|
set -a editor +$line +"norm! $col|" $f
|
||||||
set -a editor +$line,$col $f
|
case emacs emacsclient gedit kak
|
||||||
case joe ee
|
set -a editor +$line:$col $f
|
||||||
set -a editor +$line $f
|
case nano
|
||||||
case code code-oss
|
set -a editor +$line,$col $f
|
||||||
set -a editor --goto $f:$line:$col --wait
|
case joe ee
|
||||||
case subl
|
set -a editor +$line $f
|
||||||
set -a editor $f:$line:$col --wait
|
case code code-oss
|
||||||
case micro
|
set -a editor --goto $f:$line:$col --wait
|
||||||
set -a editor $f +$line:$col
|
case subl
|
||||||
case '*'
|
set -a editor $f:$line:$col --wait
|
||||||
set -a editor $f
|
case micro
|
||||||
|
set -a editor $f +$line:$col
|
||||||
|
case '*'
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
set found true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if not $found
|
||||||
|
set -a editor $f
|
||||||
end
|
end
|
||||||
|
|
||||||
__fish_disable_bracketed_paste
|
__fish_disable_bracketed_paste
|
||||||
|
|||||||
Reference in New Issue
Block a user