Merge pull request #443 from zsh-users/fixes/alias-parse-error

Prefix custom `_complete` implementation with "function" keyword
This commit is contained in:
Eric Freese 2019-06-18 07:50:07 -06:00 committed by GitHub
commit 48ffc1bf92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -20,6 +20,23 @@ describe 'the `completion` suggestion strategy' do
wait_for { session.content }.to eq("baz \\\nbar") wait_for { session.content }.to eq("baz \\\nbar")
end end
context 'when `_complete` is aliased' do
let(:before_sourcing) do
-> do
session.
run_command('autoload compinit && compinit').
run_command('_foo() { compadd bar; compadd bat }').
run_command('compdef _foo baz').
run_command('alias _complete=_complete')
end
end
it 'suggests the first completion result' do
session.send_string('baz ')
wait_for { session.content }.to eq('baz bar')
end
end
context 'when async mode is enabled' do context 'when async mode is enabled' do
let(:options) { ['ZSH_AUTOSUGGEST_USE_ASYNC=true', 'ZSH_AUTOSUGGEST_STRATEGY=completion'] } let(:options) { ['ZSH_AUTOSUGGEST_USE_ASYNC=true', 'ZSH_AUTOSUGGEST_STRATEGY=completion'] }

View file

@ -86,7 +86,7 @@ _zsh_autosuggest_capture_completion_async() {
# https://stackoverflow.com/a/7057118/154703 # https://stackoverflow.com/a/7057118/154703
autoload +X _complete autoload +X _complete
functions[_original_complete]=$functions[_complete] functions[_original_complete]=$functions[_complete]
_complete () { function _complete() {
unset 'compstate[vared]' unset 'compstate[vared]'
_original_complete "$@" _original_complete "$@"
} }

View file

@ -568,7 +568,7 @@ _zsh_autosuggest_capture_completion_async() {
# https://stackoverflow.com/a/7057118/154703 # https://stackoverflow.com/a/7057118/154703
autoload +X _complete autoload +X _complete
functions[_original_complete]=$functions[_complete] functions[_original_complete]=$functions[_complete]
_complete () { function _complete() {
unset 'compstate[vared]' unset 'compstate[vared]'
_original_complete "$@" _original_complete "$@"
} }