mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-08 15:32:31 +01:00
Adding support for ZSH_AUTOSUGGEST_BUFFER_MIN_SIZE to disable suggestions on small buffers
This commit is contained in:
parent
11d17e7fea
commit
d6334ded0b
5 changed files with 47 additions and 13 deletions
|
|
@ -25,6 +25,9 @@ describe 'a suggestion' do
|
|||
wait_for { session.content }.to eq(long_command)
|
||||
end
|
||||
|
||||
it 'is not provided when the buffer is longer than the specified length'
|
||||
it 'is not provided when the buffer is longer than the specified length' do
|
||||
session.send_string(long_command[0...(buffer_max_size + 1)])
|
||||
wait_for { session.content }.to eq(long_command[0...(buffer_max_size + 1)])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
33
spec/options/buffer_min_size_spec.rb
Normal file
33
spec/options/buffer_min_size_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
describe 'a suggestion' do
|
||||
let(:term_opts) { { width: 200 } }
|
||||
let(:command) { "echo foobar" }
|
||||
|
||||
around do |example|
|
||||
with_history(command) { example.run }
|
||||
end
|
||||
|
||||
it 'is provided for any buffer length' do
|
||||
session.send_string(command[0...-1])
|
||||
wait_for { session.content }.to eq(command)
|
||||
end
|
||||
|
||||
context 'when ZSH_AUTOSUGGEST_BUFFER_MIN_SIZE is specified' do
|
||||
let(:buffer_min_size) { 5 }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_BUFFER_MIN_SIZE=#{buffer_min_size}"] }
|
||||
|
||||
it 'is provided when the buffer is longer than the specified length' do
|
||||
session.send_string(command[0...(buffer_min_size + 1)])
|
||||
wait_for { session.content }.to eq(command)
|
||||
end
|
||||
|
||||
it 'is provided when the buffer is equal to the specified length' do
|
||||
session.send_string(command[0...(buffer_min_size)])
|
||||
wait_for { session.content }.to eq(command)
|
||||
end
|
||||
|
||||
it 'is not provided when the buffer is shorter than the specified length' do
|
||||
session.send_string(command[0...(buffer_min_size - 1)])
|
||||
wait_for { session.content }.to eq(command[0...(buffer_min_size - 1)])
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue