mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-27 22:43:41 +08:00
Prefix custom _complete
implementation with "function" keyword
For some reason, when `_complete` is aliased before sourcing the plugin, zsh was blowing up with a parse error. Adding "function" keyword makes it parse successfully. See similar issue: https://github.com/robbyrussell/oh-my-zsh/issues/6723#issuecomment-381220834 Fixes GitHub #442
This commit is contained in:
parent
3654b83ec0
commit
adb02c44a2
|
@ -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'] }
|
||||
|
||||
|
|
|
@ -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 "$@"
|
||||
}
|
||||
|
|
|
@ -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 "$@"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user