Skip to content

Commit

Permalink
Improve the handling of kill/yank sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Apr 2, 2024
1 parent 0c392fe commit f3fdcfa
Showing 1 changed file with 13 additions and 35 deletions.
48 changes: 13 additions & 35 deletions Functions/Util/.autocomplete__zle-flags
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
#!/bin/zsh
typeset -g _autocomplete__last_widget=

.autocomplete__zle-flags() {
emulate -L zsh
setopt $_autocomplete__func_opts[@]

# If no arg, assume same widget as last time.
[[ -v 1 && -n $1 ]] &&
typeset -g _autocomplete__last_widget="$1"

# Return 0 to continue, 1 to abort.
case $_autocomplete__last_widget in
( *kill-*~vi-* )
builtin zle -f kill
return 0
;;
( bracketed-paste )
builtin zle -f yank
return 0
;;
( *yank*~vi-* | vi-*put-*after )
builtin zle -f yank
return 1
;;
( vi-*put-*before )
builtin zle -f yankbefore
return 1
;;
( * )
return 0
;;
esac
}

.autocomplete__zle-flags "$@"
emulate -L zsh
setopt $_autocomplete__func_opts[@]

if (( YANK_ACTIVE )); then
local before
(( YANK_START <= CURSOR && YANK_END <= CURSOR )) &&
before=before
builtin zle -f yank$before
return 1 # Tell caller to abort.
fi

builtin zle -f kill
return 0

0 comments on commit f3fdcfa

Please sign in to comment.