mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
edit_command_buffer: also detect aliases with arguments
For example
complete my-vim --wraps 'vim -x'
This commit is contained in:
@@ -30,11 +30,16 @@ 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])
|
||||
set -l wrap_targets (complete -- $basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1')
|
||||
set -l editor_basename (string match -r '[^/]+$' -- $editor[1])
|
||||
set -l wrapped_commands
|
||||
for wrap_target in (complete -- $editor_basename | string replace -rf '^complete [^/]+ --wraps (.+)$' '$1')
|
||||
set -l tmp
|
||||
string unescape -- $wrap_target | read -at tmp
|
||||
set -a wrapped_commands $tmp[1]
|
||||
end
|
||||
set -l found false
|
||||
for alias in $basename $wrap_targets
|
||||
switch $alias
|
||||
for editor_command in $editor_basename $wrapped_commands
|
||||
switch $editor_command
|
||||
case vi vim nvim
|
||||
set -a editor +$line +"norm! $col|" $f
|
||||
case emacs emacsclient gedit kak
|
||||
|
||||
Reference in New Issue
Block a user