Add autosuggest-next and autosuggest-previous widgets; enhance async suggestion handling

This commit is contained in:
David Abutbul 2025-10-27 22:03:48 +02:00
commit bf5d77a65f
11 changed files with 629 additions and 87 deletions

View file

@ -0,0 +1,38 @@
describe 'the `autosuggest-previous` widget' do
let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=history'] }
before do
session.run_command('bindkey ^P autosuggest-previous')
end
it 'cycles backwards through history suggestions and wraps around' do
with_history do
session.run_command('echo foo')
session.run_command('echo bar')
session.run_command('echo baz')
session.clear_screen
session.send_string('echo ')
wait_for { session.content }.to eq('echo baz')
session.send_keys('C-p')
wait_for { session.content }.to eq('echo foo')
session.send_keys('C-p')
wait_for { session.content }.to eq('echo bar')
session.send_keys('C-p')
wait_for { session.content }.to eq('echo baz')
end
end
it 'leaves the buffer untouched when no suggestions are available' do
with_history do
session.send_string('foo')
wait_for { session.content }.to eq('foo')
session.send_keys('C-p')
wait_for { session.content }.to eq('foo')
end
end
end