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

Doesn't work alongside zsh-syntax-highlight? #1

Closed
blaenk opened this issue Feb 23, 2017 · 11 comments
Closed

Doesn't work alongside zsh-syntax-highlight? #1

blaenk opened this issue Feb 23, 2017 · 11 comments

Comments

@blaenk
Copy link

blaenk commented Feb 23, 2017

I noticed that zsh-syntax-highlight seems to interfere with this plugin. First I had to add defer:3 to viexchange with zplug to make it load after zsh-syntax-highlight (which I have as defer:2), so that the selection highlight would show up. Second though I noticed that after making the first selection, any movement of the cursor causes that selection to become unhighlighted and it's seemingly forgotten, since making any other exchange selection doesn't actually perform the exchange, instead it seems to wait for the second selection.

If I do another exchange operation immediately after making a selection then it does work, for example cxE followed by cxB.

I suspect perhaps any motion of the cursor causes zsh-syntax-highlight to redraw/refresh the buffer, which causes the first selection highlight to be lost?

I did notice this mailing list post which shows sample code showing use of viexchange alongside zsh-syntax-highlight, so perhaps you are open to resolving this.

@okapia
Copy link
Owner

okapia commented Feb 23, 2017

It's arguably more of a bug in zsh-syntax-highlight because that tramples on any highlighting set by any other code while vi-exchange is careful to remove only it's own entry. I don't use zsh-syntax-highlight myself but I'll e-mail the maintainer of it to see if he has any suggestions on how to make it work. Ideally, I'd like it if zsh could make it easier to manage highlighting across multiple plugins.

In the mailing list post you cite, I used those two plugins as an example because one was common and well-known and the other was my own. So don't infer too much extra meaning from that, though I am open to resolving this.

@blaenk
Copy link
Author

blaenk commented Feb 23, 2017

Got it. Is there any chance it can be made to work regardless of highlighting? I know it wouldn't be as user-friendly, but at least it'd work, and I personally can remember the first region I highlighted.

It seems like maybe the way it works right now is that it identifies the regions by looking for the part that's highlighted? Maybe if the beginning/end positions are saved it wouldn't be dependent on the highlighting working, so highlighting would simply be sugar on top?

@okapia
Copy link
Owner

okapia commented Feb 24, 2017

If you just change region_highlight to some other non-special variable as a temporary hack then I guess it would work without highlighting.

@blaenk
Copy link
Author

blaenk commented Mar 26, 2017

Would you kindly be open to making this possible through some opt-in environment variable or something, rather than having to fork this and then losing out on the changes you make in the future? I would really appreciate it!

@danielshahaf
Copy link

z-sy-h maintainer here. I've posted a patch for this issue. Unfortunately, a change to zsh itself was required as well (meaning zsh must be recompiled).

@okapia
Copy link
Owner

okapia commented Jun 23, 2020

Thanks @danielshahaf
I've applied a patch in 56fcfb6 to use the new memo feature if it is available. In practice this won't actually help with this issue because it is zsh-syntax-highlighting that is clearing region_highlight so you need a new version of that and of zsh (currently a from git build). But this update will be somewhat cleaner, especially if you use the same colour for the exchange highlighting as for something else.

@okapia okapia closed this as completed Jun 23, 2020
@danielshahaf
Copy link

The zsh patch has been merged. Further updates shall be posted to zsh-users/zsh-syntax-highlighting#418.

@blaenk
Copy link
Author

blaenk commented Jun 28, 2020

Amazing work, thanks to everyone who made this happen.

@kiprasmel
Copy link

This seems to still be broken (disabling zsh-syntax-highlighting makes it work again). I'm using the fresh build of zsh-syntax-highlighting (master branch). Any ideas anyone?

@danielshahaf
Copy link

@kiprasmel Judging by the last few comments, the fix requires zsh from git master as well, at least until 5.8.0.3 or newer is released. @okapia correct me if I'm wrong.

@kiprasmel
Copy link

okay I tried it (since I use arch btw I had to yay -S zsh-git and get rid of zsh to get the latest version).

it works now!

tho takes a while like 1 sec or smthn, but might be related to my other configurations:

https://github.com/kiprasmel/voidrice/blob/e06b82f515b35422c8230728f324786fbd9b0ad6/.zshrc

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

No branches or pull requests

4 participants