From 83129dd796b19cf888dd32aad84753fb728eead9 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Fri, 14 Apr 2017 08:48:54 -0600 Subject: [PATCH] Make asynchronous suggestions disabled by default While they are still experimental --- README.md | 4 ++-- spec/options/async_zpty_name_spec.rb | 24 ++++++++++++++---------- spec/options/use_async_spec.rb | 6 +++--- src/config.zsh | 3 --- zsh-autosuggestions.zsh | 3 --- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0d3c833..ab5c82c 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ Widgets that modify the buffer and are not found in any of these arrays will fet 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. This can be useful when pasting large amount of text in the terminal, to avoid triggering autosuggestion for too long strings. -### Disable Asynchronous Mode +### Enable Asynchronous Mode -As of `v0.4.0`, suggestions are fetched asynchronously using the `zsh/zpty` module. To disable this behavior and fall back to fetching suggestions synchronously, unset the `ZSH_AUTOSUGGEST_USE_ASYNC` variable. +As of `v0.4.0`, suggestions can be fetched asynchronously using the `zsh/zpty` module. To enable this behavior, set the `ZSH_AUTOSUGGEST_USE_ASYNC` variable (it can be set to anything). ### Key Bindings diff --git a/spec/options/async_zpty_name_spec.rb b/spec/options/async_zpty_name_spec.rb index c768f54..407ee70 100644 --- a/spec/options/async_zpty_name_spec.rb +++ b/spec/options/async_zpty_name_spec.rb @@ -1,15 +1,19 @@ -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 async suggestions are enabled' do + let(:options) { ["ZSH_AUTOSUGGEST_USE_ASYNC="] } - 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 $?') + 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) { super() + ['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 end diff --git a/spec/options/use_async_spec.rb b/spec/options/use_async_spec.rb index 8b9ebab..420dcc3 100644 --- a/spec/options/use_async_spec.rb +++ b/spec/options/use_async_spec.rb @@ -1,7 +1,7 @@ describe 'suggestion fetching' do - it 'is performed asynchronously' + it 'is performed synchronously' - context 'when ZSH_AUTOSUGGEST_USE_ASYNC is unset' do - it 'is performed synchronously' + context 'when ZSH_AUTOSUGGEST_USE_ASYNC is set' do + it 'is performed asynchronously' end end diff --git a/src/config.zsh b/src/config.zsh index a9f02e6..c7fc55a 100644 --- a/src/config.zsh +++ b/src/config.zsh @@ -61,8 +61,5 @@ ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( # Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound. ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE= -# Use asynchronous mode by default. Unset this variable to use sync mode. -ZSH_AUTOSUGGEST_USE_ASYNC= - # Pty name for calculating autosuggestions asynchronously ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 55d23b7..bdc9bcc 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -97,9 +97,6 @@ ZSH_AUTOSUGGEST_IGNORE_WIDGETS=( # Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound. ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE= -# Use asynchronous mode by default. Unset this variable to use sync mode. -ZSH_AUTOSUGGEST_USE_ASYNC= - # Pty name for calculating autosuggestions asynchronously ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty