zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

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

Open zhengyu-yang opened this issue 5 years ago • 13 comments

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: d43c309f888153d6c46d8b6a3a0186f4148680fd

zhengyu-yang avatar Dec 02 '19 07:12 zhengyu-yang

I have also submitted this bug here

zhengyu-yang avatar Dec 02 '19 07:12 zhengyu-yang

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 avatar Jan 07 '20 04:01 ericfreese

@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 avatar Jan 30 '20 04:01 ericfreese

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 😞

weslley39 avatar Feb 19 '20 17:02 weslley39

@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 avatar Feb 28 '20 22:02 nathanshelly

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

nathanshelly avatar Feb 28 '20 22:02 nathanshelly

(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)~~

danielshahaf avatar Feb 28 '20 23:02 danielshahaf

@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 <C-c> the which pip command each time so that I didn't changed the history image

ewen-goisot avatar Aug 14 '20 01:08 ewen-goisot

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

z0rc avatar Aug 14 '20 08:08 z0rc

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 avatar Aug 14 '20 21:08 danielshahaf

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.

danielshahaf avatar Aug 14 '20 21:08 danielshahaf

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

ewen-goisot avatar Aug 25 '20 11:08 ewen-goisot

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.

danielshahaf avatar Aug 26 '20 07:08 danielshahaf