about summary refs log tree commit diff
path: root/Src/Zle/zle_thingy.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/zle_thingy.c')
-rw-r--r--Src/Zle/zle_thingy.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 53eb927f9..c252eee1e 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -619,6 +619,23 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
 
 /**/
 static int
+zle_usable()
+{
+    return zleactive && !incompctlfunc && !incompfunc
+#if 0
+	/*
+	 * PWS experiment: commenting this out allows zle widgets
+	 * in signals, hooks etc.  I'm not sure if this has a down side;
+	 * it ought to be that zleactive is good enough to test whether
+	 * widgets are callable.
+	 */
+	&& sfcontext == SFC_WIDGET
+#endif
+	   ;
+}
+
+/**/
+static int
 bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 {
     Thingy t;
@@ -629,10 +646,9 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
     if (!wname) {
 	if (saveflag)
 	    zmod = modsave;
-	return (!zleactive || incompctlfunc || incompfunc ||
-		sfcontext != SFC_WIDGET);
+	return !zle_usable();
     }
-    if(!zleactive || incompctlfunc || incompfunc || sfcontext != SFC_WIDGET) {
+    if(!zle_usable()) {
 	zwarnnam(name, "widgets can only be called when ZLE is active",
 	    NULL, 0);
 	return 1;
@@ -685,10 +701,15 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 static int
 bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops), UNUSED(char func))
 {
+    /*
+     * Trash zle if trashable, but only indicate that zle is usable
+     * if it's possible to call a zle widget next.  This is not
+     * true if a completion widget is active.
+     */
     if (zleactive) {
 	if (!trashedzle)
 	    trashzle();
-	return 0;
+	return !zle_usable();
     } else
 	return 1;
 }