-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38eb7cd
commit a1067d3
Showing
35 changed files
with
387 additions
and
1,133 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--color | ||
--require spec_helper | ||
--format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Rails: | ||
# Enabled: true | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.3 | ||
Include: | ||
- '**/Rakefile' | ||
- '**/config.ru' | ||
- '**/Gemfile' | ||
|
||
Metrics/LineLength: | ||
Max: 120 | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Style/DotPosition: | ||
EnforcedStyle: trailing | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
Style/Lambda: | ||
Enabled: false | ||
|
||
Style/MultilineMethodCallIndentation: | ||
EnforcedStyle: indented | ||
|
||
Style/TrailingUnderscoreVariable: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe 'a running zpty command' do | ||
it 'is not affected by running zsh-autosuggestions' do | ||
session.run_command('zmodload zsh/zpty') | ||
session.run_command('zpty -b kitty cat') | ||
session.run_command('zpty -w kitty cat') | ||
sleep 1 | ||
session.run_command('zpty -r kitty') | ||
|
||
wait_for(session.content).to end_with("\ncat") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe 'a multi-line suggestion' do | ||
it 'should be displayed on multiple lines' do | ||
with_history(-> { | ||
session.send_string('echo "') | ||
session.send_keys('enter') | ||
session.send_string('"') | ||
session.send_keys('enter') | ||
}) do | ||
session.send_keys('e') | ||
wait_for { session.content }.to eq("echo \"\n\"") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe 'the zpty for async suggestions' do | ||
it 'is created with the default name' do | ||
session.run_command('zpty -t zsh_autosuggest_pty &>/dev/null; echo $?') | ||
wait_for { session.content }.to end_with("\n0") | ||
end | ||
|
||
context 'when ZSH_AUTOSUGGEST_ASYNC_PTY_NAME is set' do | ||
let(:options) { ['ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=foo_pty'] } | ||
|
||
it 'is created with the specified name' do | ||
session.run_command('zpty -t foo_pty &>/dev/null; echo $?') | ||
wait_for { session.content }.to end_with("\n0") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe 'a suggestion' do | ||
let(:term_opts) { { width: 200 } } | ||
let(:long_command) { "echo #{'a' * 100}" } | ||
|
||
around do |example| | ||
with_history(long_command) { example.run } | ||
end | ||
|
||
it 'is provided for any buffer length' do | ||
session.send_string(long_command[0...-1]) | ||
wait_for { session.content }.to eq(long_command) | ||
end | ||
|
||
context 'when ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE is specified' do | ||
let(:buffer_max_size) { 10 } | ||
let(:options) { ["ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=#{buffer_max_size}"] } | ||
|
||
it 'is provided when the buffer is shorter than the specified length' do | ||
session.send_string(long_command[0...(buffer_max_size - 1)]) | ||
wait_for { session.content }.to eq(long_command) | ||
end | ||
|
||
it 'is provided when the buffer is equal to the specified length' do | ||
session.send_string(long_command[0...(buffer_max_size)]) | ||
wait_for { session.content }.to eq(long_command) | ||
end | ||
|
||
it 'is not provided when the buffer is longer than the specified length' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe 'a displayed suggestion' do | ||
it 'is shown in the default style' | ||
|
||
describe 'when ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE is set to a zle_highlight string' do | ||
it 'is shown in the specified style' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe 'an original zle widget' do | ||
context 'is accessible with the default prefix' | ||
|
||
context 'when ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX is set' do | ||
it 'is accessible with the specified prefix' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe 'a suggestion for a given prefix' do | ||
let(:options) { ['_zsh_autosuggest_strategy_default() { suggestion="echo foo" }'] } | ||
|
||
it 'is determined by calling the default strategy function' do | ||
session.send_string('e') | ||
wait_for { session.content }.to eq('echo foo') | ||
end | ||
|
||
context 'when ZSH_AUTOSUGGEST_STRATEGY is set' do | ||
let(:options) { [ | ||
'_zsh_autosuggest_strategy_custom() { suggestion="echo foo" }', | ||
'ZSH_AUTOSUGGEST_STRATEGY=custom' | ||
] } | ||
|
||
it 'is determined by calling the specified strategy function' do | ||
session.send_string('e') | ||
wait_for { session.content }.to eq('echo foo') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe 'suggestion fetching' do | ||
it 'is performed asynchronously' | ||
|
||
context 'when ZSH_AUTOSUGGEST_USE_ASYNC is unset' do | ||
it 'is performed synchronously' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
describe 'a zle widget' do | ||
let(:before_sourcing) { -> { session.run_command('my-widget() {}; zle -N my-widget; bindkey ^B my-widget') } } | ||
|
||
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do | ||
let(:options) { ['ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(my-widget)'] } | ||
|
||
it 'accepts the suggestion when invoked' do | ||
with_history('echo hello') do | ||
session.send_string('e') | ||
wait_for { session.content }.to eq('echo hello') | ||
session.send_keys('C-b') | ||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello') | ||
end | ||
end | ||
end | ||
|
||
context 'when added to ZSH_AUTOSUGGEST_CLEAR_WIDGETS' do | ||
let(:options) { ['ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(my-widget)'] } | ||
|
||
it 'clears the suggestion when invoked' do | ||
with_history('echo hello') do | ||
session.send_string('e') | ||
wait_for { session.content }.to eq('echo hello') | ||
session.send_keys('C-b') | ||
wait_for { session.content }.to eq('e') | ||
end | ||
end | ||
end | ||
|
||
context 'when added to ZSH_AUTOSUGGEST_EXECUTE_WIDGETS' do | ||
let(:options) { ['ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(my-widget)'] } | ||
|
||
it 'executes the suggestion when invoked' do | ||
with_history('echo hello') do | ||
session.send_string('e') | ||
wait_for { session.content }.to eq('echo hello') | ||
session.send_keys('C-b') | ||
wait_for { session.content }.to end_with("\nhello") | ||
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_PARTIAL_ACCEPT_WIDGETS' do | ||
let(:options) { ['ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(my-widget)'] } | ||
|
||
it 'accepts the suggestion as far as the cursor is moved when invoked' do | ||
with_history('echo hello') do | ||
session.send_string('e') | ||
wait_for { session.content }.to start_with('echo hello') | ||
session.send_keys('C-b') | ||
wait_for { session.content(esc_seqs: true) }.to match(/\Aec\e\[[0-9]+mho hello/) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.