mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Clean up widget list spec
This commit is contained in:
parent
255359dbb8
commit
c70d685d15
1 changed files with 23 additions and 26 deletions
|
@ -1,8 +1,9 @@
|
|||
describe 'a zle widget' do
|
||||
let(:before_sourcing) { -> { session.run_command('my-widget() {}; zle -N my-widget; bindkey ^B my-widget') } }
|
||||
let(:widget) { 'my-widget' }
|
||||
let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } }
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(my-widget)'] }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'accepts the suggestion when invoked' do
|
||||
with_history('echo hello') do
|
||||
|
@ -15,7 +16,7 @@ describe 'a zle widget' do
|
|||
end
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_CLEAR_WIDGETS' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(my-widget)'] }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'clears the suggestion when invoked' do
|
||||
with_history('echo hello') do
|
||||
|
@ -28,7 +29,7 @@ describe 'a zle widget' do
|
|||
end
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_EXECUTE_WIDGETS' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_EXECUTE_WIDGETS+=(my-widget)'] }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_EXECUTE_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'executes the suggestion when invoked' do
|
||||
with_history('echo hello') do
|
||||
|
@ -39,13 +40,21 @@ describe 'a zle widget' do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'a zle widget that moves the cursor forward' do
|
||||
let(:before_sourcing) { -> { session.run_command('my-widget() { zle forward-char }; zle -N my-widget; bindkey ^B my-widget') } }
|
||||
context 'when added to ZSH_AUTOSUGGEST_IGNORE_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(#{widget})"] }
|
||||
|
||||
it 'should not be wrapped with an autosuggest widget' do
|
||||
session.run_command("echo $widgets[#{widget}]")
|
||||
wait_for { session.content }.to end_with("\nuser:#{widget}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'that moves the cursor forward' do
|
||||
before { session.run_command("#{widget}() { zle forward-char }") }
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS' do
|
||||
let(:options) { ['ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(my-widget)'] }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(#{widget})"] }
|
||||
|
||||
it 'accepts the suggestion as far as the cursor is moved when invoked' do
|
||||
with_history('echo hello') do
|
||||
|
@ -56,17 +65,5 @@ describe 'a zle widget that moves the cursor forward' do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'a builtin zle widget' do
|
||||
let(:widget) { 'beep' }
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_IGNORE_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(#{widget})"] }
|
||||
|
||||
it 'should not be wrapped with an autosuggest widget' do
|
||||
session.run_command("echo $widgets[#{widget}]")
|
||||
wait_for { session.content }.to end_with("\nbuiltin")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue