2018-11-23 17:18:15 +00:00
|
|
|
describe 'the `completion` suggestion strategy' do
|
|
|
|
let(:options) { ['ZSH_AUTOSUGGEST_STRATEGY=completion'] }
|
|
|
|
let(:before_sourcing) do
|
|
|
|
-> do
|
|
|
|
session.
|
|
|
|
run_command('autoload compinit && compinit').
|
2019-04-18 05:27:26 +00:00
|
|
|
run_command('_foo() { compadd bar; compadd bat }').
|
2018-11-23 17:18:15 +00:00
|
|
|
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
|
|
|
|
|
2019-04-18 05:30:48 +00:00
|
|
|
it 'does not add extra carriage returns when prefix has a line feed' do
|
|
|
|
skip '`stty` does not work inside zpty below zsh version 5.0.3' if session.zsh_version < Gem::Version.new('5.0.3')
|
|
|
|
session.send_string('baz \\').send_keys('C-v', 'C-j')
|
|
|
|
wait_for { session.content }.to eq("baz \\\nbar")
|
|
|
|
end
|
|
|
|
|
2019-06-18 04:04:31 +00:00
|
|
|
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
|
|
|
|
|
2018-11-23 17:18:15 +00:00
|
|
|
context 'when async mode is enabled' do
|
|
|
|
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
|
2019-04-18 05:30:48 +00:00
|
|
|
|
|
|
|
it 'does not add extra carriage returns when prefix has a line feed' do
|
|
|
|
skip '`stty` does not work inside zpty below zsh version 5.0.3' if session.zsh_version < Gem::Version.new('5.0.3')
|
|
|
|
session.send_string('baz \\').send_keys('C-v', 'C-j')
|
|
|
|
wait_for { session.content }.to eq("baz \\\nbar")
|
|
|
|
end
|
2018-11-23 17:18:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|