commit
40b96f6cfd
@ -0,0 +1,36 @@
|
|||||||
|
describe 'pasting using bracketed-paste-magic' do
|
||||||
|
let(:before_sourcing) do
|
||||||
|
-> do
|
||||||
|
session.
|
||||||
|
run_command('autoload -Uz bracketed-paste-magic').
|
||||||
|
run_command('zle -N bracketed-paste bracketed-paste-magic')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with suggestions disabled while pasting' do
|
||||||
|
before do
|
||||||
|
session.
|
||||||
|
run_command('bpm_init() { zle autosuggest-disable }').
|
||||||
|
run_command('bpm_finish() { zle autosuggest-enable }').
|
||||||
|
run_command('zstyle :bracketed-paste-magic paste-init bpm_init').
|
||||||
|
run_command('zstyle :bracketed-paste-magic paste-finish bpm_finish')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not show an incorrect suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.paste_string("echo #{'a' * 60}")
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq("echo #{'a' * 60}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows a suggestion after a non-modifying keystroke' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.paste_string('echo')
|
||||||
|
sleep 1
|
||||||
|
session.send_keys('left')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,24 @@
|
|||||||
|
describe 'using `zle -U`' do
|
||||||
|
let(:before_sourcing) do
|
||||||
|
-> do
|
||||||
|
session.
|
||||||
|
run_command('_zsh_autosuggest_strategy_test() { sleep 1; _zsh_autosuggest_strategy_default "$1" }').
|
||||||
|
run_command('foo() { zle -U - "echo hello" }; zle -N foo; bindkey ^B foo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:options) { ['unset ZSH_AUTOSUGGEST_USE_ASYNC', 'ZSH_AUTOSUGGEST_STRATEGY=test'] }
|
||||||
|
|
||||||
|
# TODO: This is only possible with the $KEYS_QUEUED_COUNT widget parameter, coming soon...
|
||||||
|
xit 'does not fetch a suggestion for every inserted character' do
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows a suggestion when the widget completes' do
|
||||||
|
with_history('echo hello world') do
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content(esc_seqs: true) }.to match(/\Aecho hello\e\[[0-9]+m world/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,19 @@
|
|||||||
|
describe 'the `autosuggest-disable` widget' do
|
||||||
|
before do
|
||||||
|
session.run_command('bindkey ^B autosuggest-disable')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'disables suggestions and clears the suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.send_string('echo')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content }.to eq('echo')
|
||||||
|
|
||||||
|
session.send_string(' h')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('echo h')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,42 @@
|
|||||||
|
describe 'the `autosuggest-enable` widget' do
|
||||||
|
before do
|
||||||
|
session.
|
||||||
|
run_command('typeset -g _ZSH_AUTOSUGGEST_DISABLED').
|
||||||
|
run_command('bindkey ^B autosuggest-enable')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'enables suggestions and fetches a suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.send_string('e')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('e')
|
||||||
|
|
||||||
|
session.send_keys('C-b')
|
||||||
|
session.send_string('c')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'invoked on an empty buffer' do
|
||||||
|
it 'does not fetch a suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.send_keys('C-b')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'invoked on a non-empty buffer' do
|
||||||
|
it 'fetches a suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.send_string('e')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('e')
|
||||||
|
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,24 @@
|
|||||||
|
describe 'the `autosuggest-fetch` widget' do
|
||||||
|
context 'when suggestions are disabled' do
|
||||||
|
before do
|
||||||
|
session.
|
||||||
|
run_command('bindkey ^B autosuggest-disable').
|
||||||
|
run_command('bindkey ^F autosuggest-fetch').
|
||||||
|
send_keys('C-b')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'will fetch and display a suggestion' do
|
||||||
|
with_history('echo hello') do
|
||||||
|
session.send_string('echo h')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('echo h')
|
||||||
|
|
||||||
|
session.send_keys('C-f')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
|
||||||
|
session.send_string('e')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,26 @@
|
|||||||
|
describe 'the `autosuggest-toggle` widget' do
|
||||||
|
before do
|
||||||
|
session.run_command('bindkey ^B autosuggest-toggle')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'toggles suggestions' do
|
||||||
|
with_history('echo world', 'echo hello') do
|
||||||
|
session.send_string('echo')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content }.to eq('echo')
|
||||||
|
|
||||||
|
session.send_string(' h')
|
||||||
|
sleep 1
|
||||||
|
expect(session.content).to eq('echo h')
|
||||||
|
|
||||||
|
session.send_keys('C-b')
|
||||||
|
wait_for { session.content }.to eq('echo hello')
|
||||||
|
|
||||||
|
session.send_keys('C-h')
|
||||||
|
session.send_string('w')
|
||||||
|
wait_for { session.content }.to eq('echo world')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue