Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsuccessful completion removes highlighting #90

Closed
hedning opened this issue Aug 13, 2012 · 5 comments
Closed

Unsuccessful completion removes highlighting #90

hedning opened this issue Aug 13, 2012 · 5 comments

Comments

@hedning
Copy link

hedning commented Aug 13, 2012

If completion returns an error all highlighting will be removed.
Eg. failed file expansion cat filethatdoesntexist<tab>

This patch fixes it:

diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh
index cbd63e9..4ad0106 100644
--- a/zsh-syntax-highlighting.zsh
+++ b/zsh-syntax-highlighting.zsh
@@ -105,9 +105,12 @@ typeset -gA ZSH_HIGHLIGHT_STYLES
 # Whether the command line buffer has been modified or not.
 #
 # Returns 0 if the buffer has changed since _zsh_highlight was last called.
+# This doesn't work reliably. As the buffer might be modified, but without
+# changing the text content. Eg. when file expansion fail when
+# autocompelting.
 _zsh_highlight_buffer_modified()
 {
-  [[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]]
+  true
 }

 # Whether the cursor has moved or not.
@@ -147,7 +150,7 @@ _zsh_highlight_bind_widgets()

       # Completion widget: override and rebind old one with prefix "orig-".
       completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \
-                          _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
+                          _zsh_highlight_widget_$cur_widget() { { builtin zle orig-$cur_widget -- \"\$@\"; } always { _zsh_highlight; } }; \
                           zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;

       # Builtin widget: override and make it call the builtin ".widget".
@nicoulaj
Copy link
Member

This fix is not OK, this will trigger highlighting a lot more often and make the whole shell even more slower...

@hedning
Copy link
Author

hedning commented Aug 13, 2012

Might be. Haven't seen any major slowdowns, but obvisously not ideal.

On Mon, 13 Aug 2012 14:47:08 +0200, Julien Nicoulaud notifications@github.com wrote:

This fix is not OK, this will trigger highlighting a lot more often and make the whole shell even more slower...


Reply to this email directly or view it on GitHub:
#90 (comment)

Tor Hedin Brønner

@danielshahaf
Copy link
Member

#102 and #113 are duplicates of this issue.

@danielshahaf
Copy link
Member

@hedning Why close? The issue still exists in latest master (hence I'm reopening).

@hedning
Copy link
Author

hedning commented May 1, 2016

Saw that it was duplicate, but I missed that the duplicates were closed.

@hedning hedning reopened this May 1, 2016
danielshahaf added a commit to danielshahaf/zsh-syntax-highlighting that referenced this issue Sep 5, 2016
danielshahaf added a commit to danielshahaf/zsh-syntax-highlighting that referenced this issue Sep 8, 2016
danielshahaf added a commit to danielshahaf/zsh-syntax-highlighting that referenced this issue Sep 16, 2016
@danielshahaf danielshahaf reopened this Oct 25, 2016
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Dec 25, 2017
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Jan 5, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Jan 8, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Jan 20, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Feb 11, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Feb 11, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Sep 30, 2018
phy1729 pushed a commit to phy1729/zsh-syntax-highlighting that referenced this issue Oct 12, 2018
phy1729 pushed a commit to phy1729/zsh-syntax-highlighting that referenced this issue Oct 21, 2018
danielshahaf added a commit that referenced this issue Aug 9, 2020
* feature/redrawhook:
  docs: Track making the new codepath conditional upon the 'memo=' feature.
  On the feature/redrawhook branch, changelog: Add entries for issues fixed by this branch.
  On the feature/redrawhook branch, change the detection of the 'memo=' feature to avoid a catch-22.
  driver: Make the redrawhook codepath conditional upon the memo= feature.
  On the feature/redrawhook branch, move the changelog entry to the current release's section.
  driver: Fix a bug that prevented subsequent, third-party zle-line-pre-redraw hooks from running.
  driver: Do not pass widget arguments to _zsh_highlight
  driver: Clarify comment.  No functional change.
  driver: Allow for -U in autoloaded function definition
  driver: Use idiomatic module check
  driver: Make the shadowing $WIDGET read only.
  driver: Avoid a fork in the common case.
  test harness: Actually test the new code.
  driver: Rewrite without a state variable
  noop: Make a whitespace-only change to reduce noise in the next commit.
  docs: Rewrap.
  docs: Update FAQ answer per changes on this branch.
  redo _zsh_highlight__function_callable_p
  driver: Use a different way of checking whether add-zle-hook-widget is present.
  changelog: Use a more specific link.
  changelog: Note the effect of fixing #245/#90 and an alternative.
  driver: Pass zle-line-finish arguments on to _zsh_highlight.
  driver: Hook zle-line-finish.
  driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw'
  wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants