about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-09-11 18:40:22 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-09-11 18:40:22 +0100
commitf5e8527a8c62dd59e3883b25d9c3009fb7caf4ab (patch)
tree501f7c6c8b735e2c1fa696e19932848f20dcc14d
parent7fca9bb05b5f612337f6b1863b585a9d026b6a61 (diff)
downloadzsh-f5e8527a8c62dd59e3883b25d9c3009fb7caf4ab.tar.gz
zsh-f5e8527a8c62dd59e3883b25d9c3009fb7caf4ab.tar.xz
zsh-f5e8527a8c62dd59e3883b25d9c3009fb7caf4ab.zip
36483: handle incomplete multibyte characters in bracketed-paste-magi
-rw-r--r--ChangeLog5
-rw-r--r--Functions/Zle/bracketed-paste-magic16
2 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index c2258b402..cdcd51886 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-11  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 36483: Functions/Zle/bracketed-paste-magic: use
+	[[:INCOMPLETE:]] to get rest of multibyte character.
+
 2015-09-11  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* unposted: NEWS, README: update for minor new features that
diff --git a/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic
index 49f4b6620..464c6b339 100644
--- a/Functions/Zle/bracketed-paste-magic
+++ b/Functions/Zle/bracketed-paste-magic
@@ -164,17 +164,25 @@ bracketed-paste-magic() {
 	integer bpm_limit=$UNDO_LIMIT_NO bpm_undo=$UNDO_CHANGE_NO
 	UNDO_LIMIT_NO=$UNDO_CHANGE_NO
 
+	local mbchar
+	integer ismb
 	while [[ -n $PASTED ]] && zle .read-command; do
-	    PASTED=${PASTED#$KEYS}
-	    if [[ $KEYS = ${(~j:|:)${(b)bpm_inactive}} ]]; then
-		zle .self-insert-unmeta
+	    mbchar=$KEYS
+	    ismb=0
+	    while [[ $mbchar = [[:INCOMPLETE:]]* ]] && zle .read-command; do
+		mbchar+=$KEYS
+		ismb=1
+	    done
+	    PASTED=${PASTED#$mbchar}
+	    if [[ ismb -ne 0 || $mbchar = ${(~j:|:)${(b)bpm_inactive}} ]]; then
+		LBUFFER+=$mbchar
 	    else
 		case $REPLY in
 		    (${~bpm_active}) function () {
 			emulate -L $bpm_emulate; set -$bpm_opts
 			zle $REPLY
 		    };;
-		    (*) zle .self-insert-unmeta;;
+		    (*) LBUFFER+=$mbchar;
 		esac
 	    fi
 	done