Skip to content

Commit

Permalink
Fix global param bug in zle-flags()
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Dec 6, 2021
1 parent 7727d97 commit 5d64d38
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions functions/.autocomplete.zle-flags
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/bin/zsh
emulate -L zsh
setopt $_autocomplete__func_opts[@]
typeset -gH _autocomplete__last_widget=

# If no arg, assume same widget as last time.
[[ -v 1 && -n $1 ]] &&
typeset -gH _autocomplete__last_widget="$1"
.autocomplete.zle-flags() {
emulate -L zsh
setopt $_autocomplete__func_opts[@]

# Return 0 to continue, 1 to abort.
case $_autocomplete__last_widget in
( *kill-*~vi-* )
builtin zle -f kill
return 0
;;
( *yank*~vi-* | vi-*put-*after | bracketed-paste )
builtin zle -f yank
return 1
;;
( vi-*put-*before )
builtin zle -f yankbefore
return 1
;;
( * )
return 0
;;
esac
# If no arg, assume same widget as last time.
[[ -v 1 && -n $1 ]] &&
typeset -gH _autocomplete__last_widget="$1"

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

.autocomplete.zle-flags "$@"

0 comments on commit 5d64d38

Please sign in to comment.