mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-27 22:43:41 +08:00
parent
db290c518b
commit
b9fee8a324
|
@ -69,6 +69,10 @@ This can be useful when pasting large amount of text in the terminal, to avoid t
|
|||
|
||||
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).
|
||||
|
||||
### Disabling automatic widget re-binding
|
||||
|
||||
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`.
|
||||
|
||||
|
||||
### Key Bindings
|
||||
|
||||
|
|
|
@ -94,4 +94,27 @@ describe 'a modification to the widget lists' do
|
|||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when manual rebind is enabled' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_MANUAL_REBIND=true"] }
|
||||
|
||||
it 'does not take effect until bind command is re-run' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
sleep 1
|
||||
expect(session.content(esc_seqs: true)).not_to eq('echo hello')
|
||||
|
||||
session.send_keys('C-c')
|
||||
session.run_command('_zsh_autosuggest_bind_widgets').clear_screen
|
||||
wait_for { session.content }.to eq('')
|
||||
|
||||
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
|
||||
end
|
||||
|
|
|
@ -5,15 +5,17 @@
|
|||
|
||||
# Start the autosuggestion widgets
|
||||
_zsh_autosuggest_start() {
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
# By default we re-bind widgets on every precmd to ensure we wrap other
|
||||
# wrappers. Specifically, highlighting breaks if our widgets are wrapped by
|
||||
# zsh-syntax-highlighting widgets. This also allows modifications to the
|
||||
# widget list variables to take effect on the next precmd. However this has
|
||||
# a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND
|
||||
# to disable the automatic re-binding.
|
||||
if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
fi
|
||||
|
||||
_zsh_autosuggest_bind_widgets
|
||||
|
||||
# Re-bind widgets on every precmd to ensure we wrap other wrappers.
|
||||
# Specifically, highlighting breaks if our widgets are wrapped by
|
||||
# zsh-syntax-highlighting widgets. This also allows modifications
|
||||
# to the widget list variables to take effect on the next precmd.
|
||||
add-zsh-hook precmd _zsh_autosuggest_bind_widgets
|
||||
}
|
||||
|
||||
# Start the autosuggestion widgets on the next precmd
|
||||
|
|
|
@ -669,15 +669,17 @@ _zsh_autosuggest_async_response() {
|
|||
|
||||
# Start the autosuggestion widgets
|
||||
_zsh_autosuggest_start() {
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
# By default we re-bind widgets on every precmd to ensure we wrap other
|
||||
# wrappers. Specifically, highlighting breaks if our widgets are wrapped by
|
||||
# zsh-syntax-highlighting widgets. This also allows modifications to the
|
||||
# widget list variables to take effect on the next precmd. However this has
|
||||
# a decent performance hit, so users can set ZSH_AUTOSUGGEST_MANUAL_REBIND
|
||||
# to disable the automatic re-binding.
|
||||
if (( ${+ZSH_AUTOSUGGEST_MANUAL_REBIND} )); then
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
fi
|
||||
|
||||
_zsh_autosuggest_bind_widgets
|
||||
|
||||
# Re-bind widgets on every precmd to ensure we wrap other wrappers.
|
||||
# Specifically, highlighting breaks if our widgets are wrapped by
|
||||
# zsh-syntax-highlighting widgets. This also allows modifications
|
||||
# to the widget list variables to take effect on the next precmd.
|
||||
add-zsh-hook precmd _zsh_autosuggest_bind_widgets
|
||||
}
|
||||
|
||||
# Start the autosuggestion widgets on the next precmd
|
||||
|
|
Loading…
Reference in New Issue
Block a user