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
- X-seq: zsh-workers 36871
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Chi Hsuan Yen <yan12125@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Bug: bracketed-paste-magic + ztcp causes wrong pasted contents for CJK payloads
- Date: Thu, 15 Oct 2015 17:25:03 -0700
- In-reply-to: <CAH+w=7ZJRmbk7QzprgAqL8VWf0zPYxTcoUaZOtzv8aHp4Un6LA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAMNjDR3xZP9wCuYd-3uoBBPVLa-WPa8rAgkVbPxPOC_gyZPSJg@mail.gmail.com> 	<CAH+w=7ZJRmbk7QzprgAqL8VWf0zPYxTcoUaZOtzv8aHp4Un6LA@mail.gmail.com>
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