Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads



With a ubuntu 14.04 vagrant image [1] I can reproduce this bug all the time.

And the patch listed above works on neither ubuntu 14.04 nor Arch Linux.

[1]
https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

On 16 October 2015 at 08:25, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Oct 15,  1:54pm, Bart Schaefer wrote:
> } Subject: Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted
> content
> }
> } On Thu, Oct 15, 2015 at 6:54 AM, Chi Hsuan Yen <yan12125@xxxxxxxxx>
> wrote:
> } > This bug is similar to zsh-worker 36763 but different. With zsh commit
> } > 827d360, I have no problems in pasting CJK payloads with an empty
> ~/.zshrc,
> } > while problems occur with my own ~/.zshrc.  It's a strange bug. Please
> tell
> } > me if you can't reproduce it. I'll test on more platforms.
> }
> } I am able to reproduce this, but not reliably.
>
> On the off chance that $(emulate) is somehow consuming some of the bytes
> being pasted, try this?
>
>
> diff --git a/Functions/Zle/bracketed-paste-magic
> b/Functions/Zle/bracketed-paste-magic
> index cd4a708..2368bc3 100644
> --- a/Functions/Zle/bracketed-paste-magic
> +++ b/Functions/Zle/bracketed-paste-magic
> @@ -116,10 +116,14 @@ quote-paste() {
>  # Now the actual function
>
>  bracketed-paste-magic() {
> -    # Fast exit in the vi-mode cut-buffer context
>      if [[ "$LASTWIDGET" = *vi-set-buffer ]]; then
> +       # Fast exit in the vi-mode cut-buffer context
>         zle .bracketed-paste
>         return
> +    else
> +       # Capture the pasted text in $PASTED
> +       local PASTED
> +       zle .bracketed-paste PASTED
>      fi
>
>      # Really necessary to go to this much effort?
> @@ -127,10 +131,9 @@ bracketed-paste-magic() {
>
>      emulate -L zsh
>      local -a bpm_hooks bpm_inactive
> -    local PASTED bpm_func bpm_active bpm_keymap=$KEYMAP
> +    local bpm_func bpm_active bpm_keymap=$KEYMAP
>
> -    # Set PASTED and run the paste-init functions
> -    zle .bracketed-paste PASTED
> +    # Run the paste-init functions
>      if zstyle -a :bracketed-paste-magic paste-init bpm_hooks; then
>         for bpm_func in $bpm_hooks; do
>             if (( $+functions[$bpm_func] )); then
>


Messages sorted by: Reverse Date, Date, Thread, Author