diff --git a/spec/strategies/completion_spec.rb b/spec/strategies/completion_spec.rb index e8cc8ce..2be358a 100644 --- a/spec/strategies/completion_spec.rb +++ b/spec/strategies/completion_spec.rb @@ -20,6 +20,23 @@ describe 'the `completion` suggestion strategy' do wait_for { session.content }.to eq("baz \\\nbar") 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 let(:options) { ['ZSH_AUTOSUGGEST_USE_ASYNC=true', 'ZSH_AUTOSUGGEST_STRATEGY=completion'] } diff --git a/src/strategies/completion.zsh b/src/strategies/completion.zsh index 4c60e90..dfbf6eb 100644 --- a/src/strategies/completion.zsh +++ b/src/strategies/completion.zsh @@ -86,7 +86,7 @@ _zsh_autosuggest_capture_completion_async() { # https://stackoverflow.com/a/7057118/154703 autoload +X _complete functions[_original_complete]=$functions[_complete] - _complete () { + function _complete() { unset 'compstate[vared]' _original_complete "$@" } diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index ce1e83e..318990b 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -568,7 +568,7 @@ _zsh_autosuggest_capture_completion_async() { # https://stackoverflow.com/a/7057118/154703 autoload +X _complete functions[_original_complete]=$functions[_complete] - _complete () { + function _complete() { unset 'compstate[vared]' _original_complete "$@" }