about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-11-13 11:04:25 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2016-11-13 11:04:25 -0800
commit7b8f63871372e0cd01e9ed9bf313a8a96d9a1965 (patch)
treede5c946d03c2e1e5ac91f20af057de63f29eafce /Src
parent33052104e11b04ac57ff02cee1f5bb1ef0289641 (diff)
downloadzsh-7b8f63871372e0cd01e9ed9bf313a8a96d9a1965.tar.gz
zsh-7b8f63871372e0cd01e9ed9bf313a8a96d9a1965.tar.xz
zsh-7b8f63871372e0cd01e9ed9bf313a8a96d9a1965.zip
39933: more of zlecallhook() in redrawhook()
add commentary on some of the differences
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 04b93575f..96b631eeb 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1041,28 +1041,43 @@ getrestchar(int inchar, char *outstr, int *outcount)
 #endif
 
 /**/
-void redrawhook(void)
+void
+redrawhook(void)
 {
     Thingy initthingy;
     if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
+	/* Duplicating most of zlecallhook() to save additional state */
+	int saverrflag = errflag, savretflag = retflag;
 	int lastcmd_prev = lastcmd;
 	int old_incompfunc = incompfunc;
 	char *args[2];
 	Thingy lbindk_save = lbindk, bindk_save = bindk;
+
 	refthingy(lbindk_save);
 	refthingy(bindk_save);
 	args[0] = initthingy->nam;
 	args[1] = NULL;
+
+	/* The generic redraw hook cannot be a completion function, so
+	 * temporarily reset state for special variable handling etc.
+	 */
 	incompfunc = 0;
 	execzlefunc(initthingy, args, 1);
 	incompfunc = old_incompfunc;
+
+	/* Restore errflag and retflag as zlecallhook() does */
+	errflag = saverrflag | (errflag & ERRFLAG_INT);
+	retflag = savretflag;
+
 	unrefthingy(initthingy);
 	unrefthingy(lbindk);
 	unrefthingy(bindk);
 	lbindk = lbindk_save;
 	bindk = bindk_save;
+
 	/* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so
-	 * restore lastcmd manually so that we don't mess up the global state */
+	 * restore lastcmd manually so that we don't mess up the global state
+	 */
 	lastcmd = lastcmd_prev;
     }
 }