-
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
Pasting is slow when using bracketed-paste-magic #141
Comments
Will look into what I can do to speed the paste up when using
Yeah, can you create a separate issue for interaction with |
The best solution I can think of right now would be to add a hook to Not the most elegant solution though... I'm gonna sleep on this one a bit, and see if I can come up with something a little nicer. |
I can't say I noticed much if any change w/ |
Logging another possible solution here:
I think I like this better than the solution above. Would be a little more general than detecting and dealing with |
do bindkeys stack? Would that not interfere with |
This is affecting me, too. Using zsh-autosuggestions.zsh v0.3.1. Workaround didn't work (I am not using oh-my-zsh or other plugins, btw). |
Are you using Do you see the issue without any other config? Try something like this: % zsh -f
%% source zsh-autosuggestions.zsh
%% [paste something long] |
@ericfreese I tried what you suggested, but pasting is still slow. I can try to create an animation to show how slow, if that helps. I tried using different terminals (Gnome Terminal and xterm), just in case: same result. |
@aaronjensen Please try the |
|
@ericfreese sorry, still slow :/ w/o zsh-autosuggestions and my config, paste is near instant. with it, it's slow. Trying from |
I have basically the same issue, but for me it depends on the version of zsh in use. On my Fedora 23 machines with zsh 5.2, pasting is always instantaneous. But when I ssh to a RHEL7 machines with zsh 5.0.2, it's slow. I suspect that 5.0.2 is simply to old to support bracketed paste, but I'm not sure. |
I just tried upgrading to zsh 5.2 and didn't see a performance improvement, even w/ https://github.com/zsh-users/zsh-autosuggestions/tree/fixes/slow_bracketed_paste_magic |
If you have a high enough version of zsh (5.2), I recommend using https://github.com/zsh-users/zsh/blob/master/Functions/Zle/bracketed-paste-url-magic (See http://www.zsh.org/mla/workers/2015/msg02610.html) as an alternative. |
@derimagia thanks, but that's not the problem here. @ericfreese Pasting with zsh-autosuggstions is still slow even with disabling bracketed-paste-magic, 9fb9675, zsh 5.2, and/or
Should one of those have worked for me, or are you still working/thinking on this one? Thanks! |
Like others, I am experiencing slow paste even if I am not using
(The code is in a branch in my own fork: lbolla@dac5b7f) The result is an overall speed up of autosuggestion in all cases, especially when pasting (with mouse middle click) clipboard data. |
Another effective workaround is to disable autosuggestion if $BUFFER is too large.
See lbolla@9572ccb |
@lbolla thanks for that! |
@lbolla Could you please send these two changes as pull requests so that it's easies for @ericfreese to merge them if he wants to? |
Issued PR #177 |
Same issue here, without zsh-autosuggestions my config paste instantly. Surprisingly setting ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE didnt help :( . |
@prasanthkrishnan how large is the text you tried to paste? What did you use for ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE? Also, consider that you need to set ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE before sourcing zsh-autosuggest. |
|
@prasanthkrishnan maybe silly question, but are you on the latest master fedc22e for zsh-autosuggestions? |
@aaronjensen You caught me, I was using 0.3.2. Switched to 0.3.3. ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE works now. |
Awesome. Glad that worked. I'm going to close this because it seems fixed. Thanks @lbolla |
Oh one other thing, it might be nice to have a sensible default for this. |
@aaronjensen I had a similar issue and didn't really pay attention until today I stumbled upon a working solution. I'm using zsh 5.3.1 with bracketed-paste-magic enabled, zsh-autosuggestions are from today's develop branch with async changes (but I don't think the latter is important). Putting code from this message (http://zsh-users.zsh.narkive.com/mhgulrfD/bracketed-paste-mode-in-xterm-and-urxvt#post1) helped immensely. Now paste is instant. I want to stress that I'm not using ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE. Hope that helps. Here is the suggested code just in case the link dies: # create a new keymap to use while pasting
bindkey -N paste
# make everything in this keymap call our custom widget
bindkey -R -M paste "^@"-"\M-^?" paste-insert
# these are the codes sent around the pasted text in bracketed
# paste mode.
# do the first one with both -M viins and -M vicmd in vi mode
bindkey '^[[200~' _start_paste
bindkey -M paste '^[[201~' _end_paste
# insert newlines rather than carriage returns when pasting newlines
bindkey -M paste -s '^M' '^J'
zle -N _start_paste
zle -N _end_paste
zle -N paste-insert _paste_insert
# switch the active keymap to paste mode
function _start_paste() {
bindkey -A paste main
}
# go back to our normal keymap, and insert all the pasted text in the
# command line. this has the nice effect of making the whole paste be
# a single undo/redo event.
function _end_paste() {
#use bindkey -v here with vi mode probably. maybe you want to track
#if you were in ins or cmd mode and restore the right one.
bindkey -e
LBUFFER+=$_paste_content
unset _paste_content
}
function _paste_insert() {
_paste_content+=$KEYS
}
function _zle_line_init() {
# Tell terminal to send escape codes around pastes.
[[ $TERM == rxvt-unicode || $TERM == xterm ]] && printf '\e[?2004h'
}
function _zle_line_finish() {
# Tell it to stop when we leave zle, so pasting in other programs
# doesn't get the ^[[200~ codes around the pasted text.
[[ $TERM == rxvt-unicode || $TERM == xterm ]] && printf '\e[?2004l'
} Rest of the messageAlternatively, you can also do stuff to the text before inserting it, I have this additional stuff which lets me toggle a mode where all the pasted text is automatically quoted and a space is appended, which is useful when pasting (some) urls with ? and & and what have you.
|
@ericfreese I wonder why I didn't have have any effect on pasting speed with turned on bracketed paste mode until I yesterday added the code from my comment above. Your understanding of zsh is way better, do you, by any chance, know why that might be the case? Sorry for scattering discussions around, but do you think this same technique could be used to help with #136? I've tried changing the code above to this hoping that bindkey ' cd ' _start_paste
bindkey -M paste "\n" _end_paste but it only made mc hang upon the start. Basically I thought of a way to disable ANY zsh hooks altogether, just as in bracketed paste mode, before mc sends its long cd path and enable hooks after the path has been sent. mc sends commands likes this: |
@balta2ar Thanks, though it looks like that suggestion, if I understand it correctly, is effectively disabling and replacing bracketed paste magic. |
Because every character pasted attempts to autosuggest, pasting something is slow.
Ideally this plugin would support bracketed paste mode out of the box (or the completions would be async as proposed in #134
The text was updated successfully, but these errors were encountered: