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

Conflict with zsh-users/zsh-syntax-highlighting #483

Open
zhengyu-yang opened this issue Dec 2, 2019 · 13 comments
Open

Conflict with zsh-users/zsh-syntax-highlighting #483

zhengyu-yang opened this issue Dec 2, 2019 · 13 comments
Labels

Comments

@zhengyu-yang
Copy link

Describe the bug

There are conflicted between zsh-users/zsh-syntax-highlighting and zsh-users/zsh-autosuggestions. With both plugins activated, if one continuously uses ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS, the last word of the suggestion will be duplicated.

To Reproduce

Steps to reproduce the behavior:

% zsh -df
% source path/to/zsh-autosuggestions.zsh
% source path/to/zsh-syntax-highlighting.plugin.zsh
% export WORDCHARS='*?_[]~=&;!#$%^(){}'
% cd Test1/Test2

Now, input cd and continuously use ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS until the end of the line. Instead of get the complete Test1/Test2, the Test2 part will be duplicated.

Expected behavior

cd Test1/Test2

Actual behavior

cd Test1/Test2Test2

Desktop

  • OS + distribution: macOS 10.15.1
  • Zsh version: 5.7.1
  • Plugin version: d43c309
@zhengyu-yang
Copy link
Author

I have also submitted this bug here

@ericfreese
Copy link
Member

I'm not able to reproduce this either. What are you using to trigger ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS? What version of z-sy-h?

ericfreese added a commit that referenced this issue Jan 30, 2020
When z-sy-h is enabled after autosuggestion widgets have already been
bound, partial accepting the last part of a suggestion will result in
that string being duplicated.

I was able to reproduce using the following versions of the two plugins:
- z-sy-h: dde84e1b25f059a298ce3189cddfd0778f998df3
- z-asug: ae315de

and running the following commands interactively one after another:

```
zsh -df
% source path/to/zsh-autosuggestions.zsh
% source path/to/zsh-syntax-highlighting.zsh
% bindkey -e
% bindkey <alt-f>         # shows `bindkey -e-e`

The order of the `source` statements matters and the issue cannot be
reproduced if the two source statements are executed together on one
line.

The problem is very similar to this one:
  #126 (comment)

See GitHub issue #483
@ericfreese
Copy link
Member

@elony314 I was able to reproduce this and put up PR #507 to fix. Give that branch (fixes/partial-accept-duplicate-word) a shot and let me know if it looks good to you.

ericfreese added a commit that referenced this issue Jan 30, 2020
When z-sy-h is enabled after autosuggestion widgets have already been
bound, partial accepting the last part of a suggestion will result in
that string being duplicated.

I was able to reproduce using the following versions of the two plugins:
- z-sy-h: dde84e1b25f059a298ce3189cddfd0778f998df3
- z-asug: ae315de

and running the following commands interactively one after another:

```
zsh -df
% source path/to/zsh-autosuggestions.zsh
% source path/to/zsh-syntax-highlighting.zsh
% bindkey -e
% bindkey <alt-f>         # shows 'bindkey -e-e'
```

The order of the `source` statements matters and the issue cannot be
reproduced if the two source statements are executed together on one
line.

The problem is very similar to this one:
  #126 (comment)

See GitHub issue #483
@weslley39
Copy link

weslley39 commented Feb 19, 2020

Hi folks, first of all, amazing work that you guys are doing.

I came across this issue, but I don't know for sure If is the same.

I record a gif to show what is happening.

ezgif-7-0841c4d7145c

What I did, typed cd, pasted something and then pressed the right arrow key.
The suggestion was duplicated because was the last command that I used.

UPDATE: I gave I try to the branch fixes/partial-accept-duplicate-word and is not working for me 😞

@nathanshelly
Copy link

nathanshelly commented Feb 28, 2020

@weslley39 I think the original poster was describing the issue from this gif:

partial-accept

I've opened a related issue (https://github.com/zdharma/fast-syntax-highlighting/issues/177) on the plugin I use for syntax highlighting.

Weirdly I haven't been able to repro the same bug you're seeing on my machine but I have a coworker with a very similar setup who has reproed - http://g.recordit.co/Z7NTQJ0lp4.gif

@nathanshelly
Copy link

nathanshelly commented Feb 28, 2020

In the meantime, a temporary workaround that seems fine so far on my machine is to use fast-syntax-highlighting without the asynchronous loading.

@elony314 would be curious if switching to https://github.com/zdharma/fast-syntax-highlighting fixes the issue for you

@danielshahaf
Copy link
Member

danielshahaf commented Feb 28, 2020

(Or try zsh-syntax-highlighting's feature/redrawhook branch)

(See zsh-users/zsh-syntax-highlighting#579, though; tl;dr: there's a known issue, but it has a known fix)

@ewen-goisot
Copy link

@ericfreese
I was or wasn't able to reproduce it, depending on how many times I sourced my ~/.zshrc file:
if I source it xxx times, it gives me xxx times too me xxx extra times the last word of the command.
Note: in my example, I cancelled with the which pip command each time so that I didn't changed the history
image

@z0rc
Copy link

z0rc commented Aug 14, 2020

@ewen-goisot source ~/.zshrc isn't doing what you expect it's doing. source ~/.zshrc doesn't reload your zsh configuration and actually is a way to break your shell in multiple ways, with or without zsh-asug and z-syhl. In order to reload your zsh configuration do exec zsh. It's unreasonable to expect that plugins would continue working as expected after source ~/.zshrc.

@danielshahaf
Copy link
Member

source ~/.zshrc doesn't reload your zsh configuration and actually is a way to break your shell in multiple ways, with or without zsh-asug and z-syhl. In order to reload your zsh configuration do exec zsh.

Whether source ~/.zshrc is or isn't a good idea isn't an absolute truth; it's a function of how the zshrc itself is written. (And exec zsh has its downsides too)

It's unreasonable to expect that plugins would continue working as expected after source ~/.zshrc.

FWIW, in z-sy-h's case, sourcing zsh-syntax-highlighting.zsh multiple times should work just fine, though highlighting would be computed multiple times, which would result in slowness.

@danielshahaf
Copy link
Member

Separately, the z-sy-h redrawhook branch was merged this week, so anyone who saw z-asug issues that were related to z-sy-h should update z-sy-h to latest master and see if the problems persist.

@ewen-goisot
Copy link

ewen-goisot commented Aug 25, 2020

@ewen-goisot source ~/.zshrc isn't doing what you expect it's doing. source ~/.zshrc doesn't reload your zsh configuration and actually is a way to break your shell in multiple ways, with or without zsh-asug and z-syhl. In order to reload your zsh configuration do exec zsh. It's unreasonable to expect that plugins would continue working as expected after source ~/.zshrc.

exec zsh works better (I don't get the last word repeated), you are perfectly right about this.
But source ~/.zshrc is the only way for me to get this bug (the last word repeated).

though highlighting would be computed multiple times, which would result in slowness

it can become very slow, because the sourcing time does not increase linearly (it's something between quadratic and exponential: if I run it 50 times, the last one needs 111.55 seconds for me.

@danielshahaf
Copy link
Member

danielshahaf commented Aug 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants