mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-08 15:32:31 +01:00
Add autosuggest-next and autosuggest-previous widgets; enhance async suggestion handling
This commit is contained in:
parent
85919cd1ff
commit
bf5d77a65f
11 changed files with 629 additions and 87 deletions
38
spec/widgets/next_spec.rb
Normal file
38
spec/widgets/next_spec.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
describe 'the `autosuggest-next` widget' do
|
||||
let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=history'] }
|
||||
|
||||
before do
|
||||
session.run_command('bindkey ^N autosuggest-next')
|
||||
end
|
||||
|
||||
it 'cycles 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-n')
|
||||
wait_for { session.content }.to eq('echo bar')
|
||||
|
||||
session.send_keys('C-n')
|
||||
wait_for { session.content }.to eq('echo foo')
|
||||
|
||||
session.send_keys('C-n')
|
||||
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-n')
|
||||
wait_for { session.content }.to eq('foo')
|
||||
end
|
||||
end
|
||||
end
|
||||
38
spec/widgets/previous_spec.rb
Normal file
38
spec/widgets/previous_spec.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue