Skip to content

Commit a411ef3

Browse files
authored
Merge pull request #613 from zsh-users/develop
v0.7.0
2 parents ae315de + fcca875 commit a411ef3

16 files changed

+125
-97
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.7.0
4+
- Enable asynchronous mode by default (#498)
5+
- No longer wrap user widgets starting with `autosuggest-` prefix (#496)
6+
- Fix a bug wrapping widgets that modify the buffer (#541)
7+
8+
39
## v0.6.4
410
- Fix `vi-forward-char` triggering a bell when using it to accept a suggestion (#488)
511
- New configuration option to skip completion suggestions when buffer matches a pattern (#487)

INSTALL.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
2. Add the plugin to the list of plugins for Oh My Zsh to load (inside `~/.zshrc`):
4040

4141
```sh
42-
plugins=(zsh-autosuggestions)
42+
plugins=(
43+
# other plugins...
44+
zsh-autosuggestions
45+
)
4346
```
4447

4548
3. Start a new terminal session.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Copyright (c) 2013 Thiago de Arruda
2-
Copyright (c) 2016-2019 Eric Freese
2+
Copyright (c) 2016-2021 Eric Freese
33

44
Permission is hereby granted, free of charge, to any person
55
obtaining a copy of this software and associated documentation

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,25 @@ Widgets that modify the buffer and are not found in any of these arrays will fet
7979
Set `ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE` to an integer value to disable autosuggestion for large buffers. The default is unset, which means that autosuggestion will be tried for any buffer size. Recommended value is 20.
8080
This can be useful when pasting large amount of text in the terminal, to avoid triggering autosuggestion for strings that are too long.
8181

82-
### Enable Asynchronous Mode
82+
### Asynchronous Mode
8383

84-
As of `v0.4.0`, suggestions can be fetched asynchronously. To enable this behavior, set the `ZSH_AUTOSUGGEST_USE_ASYNC` variable (it can be set to anything).
84+
Suggestions are fetched asynchronously by default in zsh versions 5.0.8 and greater. To disable asynchronous suggestions and fetch them synchronously instead, `unset ZSH_AUTOSUGGEST_USE_ASYNC` after sourcing the plugin.
85+
86+
Alternatively, if you are using a version of zsh older than 5.0.8 and want to enable asynchronous mode, set the `ZSH_AUTOSUGGEST_USE_ASYNC` variable after sourcing the plugin (it can be set to anything). Note that there is [a bug](https://github.com/zsh-users/zsh-autosuggestions/issues/364#issuecomment-481423232) in versions of zsh older than 5.0.8 where <kbd>ctrl</kbd> + <kbd>c</kbd> will fail to reset the prompt immediately after fetching a suggestion asynchronously.
8587

8688
### Disabling automatic widget re-binding
8789

8890
Set `ZSH_AUTOSUGGEST_MANUAL_REBIND` (it can be set to anything) to disable automatic widget re-binding on each precmd. This can be a big boost to performance, but you'll need to handle re-binding yourself if any of the widget lists change or if you or another plugin wrap any of the autosuggest widgets. To re-bind widgets, run `_zsh_autosuggest_bind_widgets`.
8991

9092
### Ignoring history suggestions that match a pattern
9193

92-
Set `ZSH_AUTOSUGGEST_HISTORY_IGNORE` to a glob pattern to prevent offering suggestions for history entries that match the pattern. For example, set it to `"cd *"` to never suggest any `cd` commands from history. Or set to `"?(#c50,)"` to never suggest anything 50 characters or longer.
94+
Set `ZSH_AUTOSUGGEST_HISTORY_IGNORE` to a [glob pattern](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators) to prevent offering suggestions for history entries that match the pattern. For example, set it to `"cd *"` to never suggest any `cd` commands from history. Or set to `"?(#c50,)"` to never suggest anything 50 characters or longer.
9395

9496
**Note:** This only affects the `history` and `match_prev_cmd` suggestion strategies.
9597

9698
### Skipping completion suggestions for certain cases
9799

98-
Set `ZSH_AUTOSUGGEST_COMPLETION_IGNORE` to a glob pattern to prevent offering completion suggestions when the buffer matches that pattern. For example, set it to `"git *"` to disable completion suggestions for git subcommands.
100+
Set `ZSH_AUTOSUGGEST_COMPLETION_IGNORE` to a [glob pattern](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators) to prevent offering completion suggestions when the buffer matches that pattern. For example, set it to `"git *"` to disable completion suggestions for git subcommands.
99101

100102
**Note:** This only affects the `completion` suggestion strategy.
101103

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.6.4
1+
v0.7.0

ZSH_VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
5.5.1
1515
5.6.2
1616
5.7.1
17+
5.8

spec/multi_line_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
describe 'a multi-line suggestion' do
22
it 'should be displayed on multiple lines' do
3-
with_history(-> {
4-
session.send_string('echo "')
5-
session.send_keys('enter')
6-
session.send_string('"')
7-
session.send_keys('enter')
8-
}) do
3+
with_history("echo \"\n\"") do
94
session.send_keys('e')
105
wait_for { session.content }.to eq("echo \"\n\"")
116
end

spec/options/use_async_spec.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

spec/spec_helper.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'pry'
22
require 'rspec/wait'
33
require 'terminal_session'
4+
require 'tempfile'
45

56
RSpec.shared_context 'terminal session' do
67
let(:term_opts) { {} }
@@ -21,18 +22,20 @@
2122
end
2223

2324
def with_history(*commands, &block)
24-
session.run_command('fc -p')
25+
Tempfile.create do |f|
26+
f.write(commands.map{|c| c.gsub("\n", "\\\n")}.join("\n"))
27+
f.flush
2528

26-
commands.each do |c|
27-
c.respond_to?(:call) ? c.call : session.run_command(c)
28-
end
29+
session.run_command('fc -p')
30+
session.run_command("fc -R #{f.path}")
2931

30-
session.clear_screen
32+
session.clear_screen
3133

32-
yield block
34+
yield block
3335

34-
session.send_keys('C-c')
35-
session.run_command('fc -P')
36+
session.send_keys('C-c')
37+
session.run_command('fc -P')
38+
end
3639
end
3740
end
3841

spec/strategies/special_characters_helper.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,71 @@
11
shared_examples 'special characters' do
2-
describe 'a special character in the buffer' do
3-
it 'should be treated like any other character' do
2+
describe 'a special character in the buffer should be treated like any other character' do
3+
it 'asterisk' do
44
with_history('echo "hello*"', 'echo "hello."') do
55
session.send_string('echo "hello*')
66
wait_for { session.content }.to eq('echo "hello*"')
77
end
8+
end
89

10+
it 'question mark' do
911
with_history('echo "hello?"', 'echo "hello."') do
1012
session.send_string('echo "hello?')
1113
wait_for { session.content }.to eq('echo "hello?"')
1214
end
15+
end
1316

17+
it 'backslash' do
1418
with_history('echo "hello\nworld"') do
1519
session.send_string('echo "hello\\')
1620
wait_for { session.content }.to eq('echo "hello\nworld"')
1721
end
22+
end
1823

24+
it 'double backslash' do
1925
with_history('echo "\\\\"') do
2026
session.send_string('echo "\\\\')
2127
wait_for { session.content }.to eq('echo "\\\\"')
2228
end
29+
end
2330

31+
it 'tilde' do
2432
with_history('echo ~/foo') do
2533
session.send_string('echo ~')
2634
wait_for { session.content }.to eq('echo ~/foo')
2735
end
36+
end
2837

38+
it 'parentheses' do
2939
with_history('echo "$(ls foo)"') do
3040
session.send_string('echo "$(')
3141
wait_for { session.content }.to eq('echo "$(ls foo)"')
3242
end
43+
end
3344

45+
it 'square bracket' do
3446
with_history('echo "$history[123]"') do
3547
session.send_string('echo "$history[')
3648
wait_for { session.content }.to eq('echo "$history[123]"')
3749
session.send_string('123]')
3850
wait_for { session.content }.to eq('echo "$history[123]"')
3951
end
52+
end
4053

54+
it 'octothorpe' do
4155
with_history('echo "#yolo"') do
4256
session.send_string('echo "#')
4357
wait_for { session.content }.to eq('echo "#yolo"')
4458
end
59+
end
4560

46-
with_history('echo "#foo"', 'echo $#abc') do
47-
session.send_string('echo "#')
48-
wait_for { session.content }.to eq('echo "#foo"')
49-
end
50-
61+
it 'caret' do
5162
with_history('echo "^A"', 'echo "^B"') do
5263
session.send_string('echo "^A')
5364
wait_for { session.content }.to eq('echo "^A"')
5465
end
66+
end
5567

68+
it 'dash' do
5669
with_history('-foo() {}') do
5770
session.send_string('-')
5871
wait_for { session.content }.to eq('-foo() {}')

0 commit comments

Comments
 (0)