zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.54k stars 1.87k forks source link

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

Open zhengyu-yang opened 4 years ago

zhengyu-yang commented 4 years ago

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

zhengyu-yang commented 4 years ago

I have also submitted this bug here

ericfreese commented 4 years ago

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 commented 4 years ago

@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.

weslley39 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

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

ewen-goisot commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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.

Replied to that over on https://github.com/zsh-users/zsh-syntax-highlighting/issues/625.