Add spec for `completion` strategy
This commit is contained in:
parent
7d19f8f9b2
commit
973205005c
|
@ -0,0 +1,30 @@
|
|||
describe 'the `completion` suggestion strategy' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=completion'] }
|
||||
let(:before_sourcing) do
|
||||
-> do
|
||||
session.
|
||||
run_command('autoload compinit && compinit').
|
||||
run_command('_foo() { compadd bar }').
|
||||
run_command('compdef _foo baz')
|
||||
end
|
||||
end
|
||||
|
||||
it 'suggests the first completion result' do
|
||||
session.send_string('baz ')
|
||||
wait_for { session.content }.to eq('baz bar')
|
||||
end
|
||||
|
||||
context 'when async mode is enabled' do
|
||||
before do
|
||||
skip 'Async mode not supported below v5.0.8' if session.zsh_version < Gem::Version.new('5.0.8')
|
||||
end
|
||||
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_USE_ASYNC=true', 'ZSH_AUTOSUGGEST_STRATEGY=completion'] }
|
||||
|
||||
it 'suggests the first completion result' do
|
||||
session.send_string('baz ')
|
||||
wait_for { session.content }.to eq('baz bar')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require 'strategies/special_characters_helper'
|
||||
|
||||
describe 'the match_prev_cmd strategy' do
|
||||
describe 'the `match_prev_cmd` strategy' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd'] }
|
||||
|
||||
it 'suggests the last matching history entry after the previous command' do
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
_zsh_autosuggest_capture_setup() {
|
||||
zmodload zsh/zutil # For `zparseopts`
|
||||
|
||||
autoload compinit && compinit
|
||||
# Ensure completions have been initialized
|
||||
if ! whence compdef >/dev/null; then
|
||||
autoload -Uz compinit && compinit
|
||||
fi
|
||||
|
||||
# There is a bug in zpty module (fixed in zsh/master) by which a
|
||||
# zpty that exits will kill all zpty processes that were forked
|
||||
|
|
|
@ -506,7 +506,10 @@ zle -N autosuggest-toggle _zsh_autosuggest_widget_toggle
|
|||
_zsh_autosuggest_capture_setup() {
|
||||
zmodload zsh/zutil # For `zparseopts`
|
||||
|
||||
autoload compinit && compinit
|
||||
# Ensure completions have been initialized
|
||||
if ! whence compdef >/dev/null; then
|
||||
autoload -Uz compinit && compinit
|
||||
fi
|
||||
|
||||
# There is a bug in zpty module (fixed in zsh/master) by which a
|
||||
# zpty that exits will kill all zpty processes that were forked
|
||||
|
|
Loading…
Reference in New Issue