-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Maybe fix for slow pastes #238
Comments
Thanks for this @aaronjensen. I think it's an interesting idea, but as far as I can tell won't be super-straightforward to implement. I don't think I'll have time to look deeper into this until the fall, but if you're interested, it would probably be good to read through I'm curious though- what is your use case for bracketed-paste-magic? Have you considered disabling it? Edit: You may be able to get something working for your personal config by saving the bound widget to some global variable on paste-init (you can get with Maybe something like this? paste-init() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
paste-finish() {
zle -N self-insert $OLD_SELF_INSERT
} |
Thanks for the suggestion, this seems to work on first test. Do you know why it breaks zsh-syntax-highlighting? FWIW, it doesn't work 100% for me even without this, it's just that with this, it breaks differently. Without the above fix it strips all of the highlighting: With the above fix it strips one char worth of highlighting for each character that bracketed paste magic adds. Pasting a command that has highlighting behaves the same either way, what is pasted is inverted until you hit something, then the syntax highlighting takes over. So I think there's actually just a bug between zsh-sytnax-highlighting and bracketed-paste-magic, I'm not sure that your suggested fix above breaks anything further. I'm going to run with it for a while, having the instance paste back is awesome! |
@ericfreese FYI, this is still working great for me. What would you think about including this built in? |
The patch mentioned in #219 should be included as of zsh v5.4, and should make all of this Would you mind trying out 5.4 or greater and reporting back? |
afaict, any sort of early return from within fwiw removing |
Going to close this issue as it seems the |
Works for me. Thanks again for your help. For posterity: # This speeds up pasting w/ autosuggest
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish |
@aaronjensen This didn't cut it for me :
I'm not sure what I did wrong and how to fix it. I was redirected from #351 as I mostly wanted to disable autosuggestions when something is pasted in the shell. e.g. when |
@bric3, I experience this bug as well. The above fix isn't really intended to address that, it's intended to make pasting fast, which it does for me. It seems there could still be an issue with either that fix or with zsh-autosuggestions. |
@aaronjensen OK, indeed, it works in that regard ! |
Where does one use apply this?
|
I put mine in my |
The proposed fix works for me but why is it not added to zsh-autosuggestions and needs to be applied manually? |
good job!! |
I fixed this issue by adding the following line to my zstyle ':bracketed-paste-magic' active-widgets '.self-*' maybe this advice should be added to the readme. What do you think @ericfreese? |
Just for curiosity, apart from the simpleness, does it have any gain over the solution above? #238 (comment) I tested here and it apparently works just as good. |
As far as I can tell, it disables bpm. Try pasting a URI w/ & or ?. They don't get escaped when using |
@aaronjensen they don't get escaped for me either, using |
Then I'd recommend the original approach, which allows bpm to still work. |
Thanks for pointing it out @felipecrs and @aaronjensen. I didn't test my solution for copied URLs that contain |
I'd also like to know why this can't be included directly in zsh-autosuggestions |
Howdy, I think I may have a solution for slow pastes (#141 #219) but I'm not sure if there are problems with it or what the best way to actually implement it is.
I believe that the paste slowdown comes from the additional zle invocation to call the original widget on self-insert. Rather than doing that, if, on disable, we replace self-insert with the original widget and then on enable, we replace it back, things are snappy.
Here is my naive implementation:
Obviously we shouldn't hard-code
url-quote-magic
or_zsh_autosuggest_bound_1_self-insert
but I wasn't sure of the best way to get the right ones in there.Thoughts? Suggestions? Thanks!
The text was updated successfully, but these errors were encountered: