summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_utils.c5
-rw-r--r--Test/X02zlevi.ztst7
3 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 64d0820be..5609754f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-13  Oliver Kiddle  <opk@zsh.org>
+
+	* 33669: Src/Zle/zle_utils.c, Test/X02zlevi.ztst: allow an empty
+	line to be yanked with yy by allocating 1 byte instead of 0
+
 2014-11-11  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 33658: Doc/Zsh/options.yo: AUTO_CD depends on SHIN_STDIN.
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 03a2bdca7..f56063e82 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -916,7 +916,7 @@ cut(int i, int ct, int flags)
 void
 cuttext(ZLE_STRING_T line, int ct, int flags)
 {
-    if (!ct || zmod.flags & MOD_NULL)
+    if (!(ct || vilinerange) ||  zmod.flags & MOD_NULL)
 	return;
 
     UNMETACHECK();
@@ -989,8 +989,9 @@ cuttext(ZLE_STRING_T line, int ct, int flags)
 	cutbuf.buf = s;
 	cutbuf.len += ct;
     } else {
+	/* don't alloc 0 bytes; length 0 occurs for blank lines in vi mode */
 	cutbuf.buf = realloc((char *)cutbuf.buf,
-			     (cutbuf.len + ct) * ZLE_CHAR_SIZE);
+			     (cutbuf.len + (ct ? ct : 1)) * ZLE_CHAR_SIZE);
 	ZS_memcpy(cutbuf.buf + cutbuf.len, line, ct);
 	cutbuf.len += ct;
     }
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index 7e5385bfe..4b9c4d91f 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -30,6 +30,13 @@
 >BUFFER: one
 >CURSOR: 0
 
+  zletest $'1\eo\eyya2\epa3'
+0:yank and paste blank line
+>BUFFER: 1
+>2
+>3
+>CURSOR: 5
+
   zletest $' four\eO\C-v\tthree\eO  two\eOone\e3J'
 0:join lines with line count
 >BUFFER: one two three