about summary refs log tree commit diff
path: root/Src/Zle/zle_vi.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-10-23 21:47:23 +0200
committerOliver Kiddle <opk@zsh.org>2014-10-23 21:47:23 +0200
commitbdedf7b40b85f54979c1e9d19445f8dfbf64967d (patch)
treea91adc0b090d92f7949a9bfadaa55280ad543a3b /Src/Zle/zle_vi.c
parent72c666fb4fd2ad4551a83f4cc40f99fa491afa92 (diff)
downloadzsh-bdedf7b40b85f54979c1e9d19445f8dfbf64967d.tar.gz
zsh-bdedf7b40b85f54979c1e9d19445f8dfbf64967d.tar.xz
zsh-bdedf7b40b85f54979c1e9d19445f8dfbf64967d.zip
33518: add support for "_ vi buffer and arguments to vi-set-buffer from a zle widget
Diffstat (limited to 'Src/Zle/zle_vi.c')
-rw-r--r--Src/Zle/zle_vi.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 2555c6a00..20cece0a8 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -782,7 +782,7 @@ viputbefore(UNUSED(char **args))
     int n = zmult;
 
     startvichange(-1);
-    if (n < 0)
+    if (n < 0 || zmod.flags & MOD_NULL)
 	return 1;
     if (zmod.flags & MOD_VIBUF)
 	buf = &vibuf[zmod.vibuf];
@@ -814,7 +814,7 @@ viputafter(UNUSED(char **args))
     int n = zmult;
 
     startvichange(-1);
-    if (n < 0)
+    if (n < 0 || zmod.flags & MOD_NULL)
 	return 1;
     if (zmod.flags & MOD_VIBUF)
 	buf = &vibuf[zmod.vibuf];
@@ -905,14 +905,26 @@ vicapslockpanic(UNUSED(char **args))
 
 /**/
 int
-visetbuffer(UNUSED(char **args))
+visetbuffer(char **args)
 {
     ZLE_INT_T ch;
 
-    if ((zmod.flags & MOD_VIBUF) ||
-	(((ch = getfullchar(0)) < ZWC('0') || ch > ZWC('9')) &&
+    if (*args) {
+	ch = **args;
+	if (args[1] || (ch && (*args)[1]))
+	    return 1;
+    } else {
+	ch = getfullchar(0);
+    }
+    if (ch == ZWC('_')) {
+	zmod.flags |= MOD_NULL;
+	prefixflag = 1;
+	return 0;
+    } else
+	zmod.flags &= ~MOD_NULL;
+    if ((ch < ZWC('0') || ch > ZWC('9')) &&
 	 (ch < ZWC('a') || ch > ZWC('z')) &&
-	 (ch < ZWC('A') || ch > ZWC('Z'))))
+	 (ch < ZWC('A') || ch > ZWC('Z')))
 	return 1;
     if (ch >= ZWC('A') && ch <= ZWC('Z'))	/* needed in cut() */
 	zmod.flags |= MOD_VIAPP;