From 0d3bbaf8e6eee660190a4bb1158a60ea6d39374c Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Mon, 27 May 2019 13:37:25 -0600 Subject: [PATCH] Remove hard-coded ignore of zle-* widgets and add to default config Use case suggested by @romkatv uses zle-line-init to restore buffer after running a widget to cd up one level (GitHub #431). As far as I can tell, the ignoring of zle-line-* was added in commit 9788c2e to support some deprecation warnings that were removed some time ago. The pattern was then widened in commit 0c940e7 to zle-* to fix problems encountered when wrapping zle-isearch-update. This commit removes the hard coded ignore of all zle-* widgets and adds zle-* to the default list of widgets to be ignored. Users who want the plugin to wrap zle-line-init or zle-line-finish can override the default. --- spec/line_init_spec.rb | 17 +++++++++++++++++ src/bind.zsh | 1 - src/config.zsh | 1 + zsh-autosuggestions.zsh | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 spec/line_init_spec.rb diff --git a/spec/line_init_spec.rb b/spec/line_init_spec.rb new file mode 100644 index 0000000..826277f --- /dev/null +++ b/spec/line_init_spec.rb @@ -0,0 +1,17 @@ +context 'with zle-line-init unignored' do + let(:after_sourcing) do + -> do + session. + run_command('setopt extendedglob'). + run_command('ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(${(@)ZSH_AUTOSUGGEST_IGNORE_WIDGETS:#zle-\*} zle-\^line-init)'). + run_command('zle-line-init() { BUFFER="echo" }') + end + end + + it 'should fetch a suggestion on each line initialization' do + with_history('echo foo') do + session.run_command('zle -N zle-line-init') + wait_for { session.content }.to end_with('echo foo') + end + end +end diff --git a/src/bind.zsh b/src/bind.zsh index a2e86e1..fc2da9e 100644 --- a/src/bind.zsh +++ b/src/bind.zsh @@ -69,7 +69,6 @@ _zsh_autosuggest_bind_widgets() { ignore_widgets=( .\* _\* - zle-\* autosuggest-\* $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* $ZSH_AUTOSUGGEST_IGNORE_WIDGETS diff --git a/src/config.zsh b/src/config.zsh index 4e82c42..5a0ebd8 100644 --- a/src/config.zsh +++ b/src/config.zsh @@ -84,6 +84,7 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- which-command yank yank-pop + zle-\* ) } diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 5f920c9..f2fe337 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -110,6 +110,7 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- which-command yank yank-pop + zle-\* ) } @@ -198,7 +199,6 @@ _zsh_autosuggest_bind_widgets() { ignore_widgets=( .\* _\* - zle-\* autosuggest-\* $ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\* $ZSH_AUTOSUGGEST_IGNORE_WIDGETS