summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_main.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-07-31 19:36:53 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-07-31 19:36:53 +0000
commit9a17762b0cdf0112f54a86e7937118422ba65614 (patch)
tree7165ef07313cc3944d53264c0a7c22e463f4fd45 /Src/Zle/zle_main.c
parent1682d0cc109c6890b939fe96cee6c9c3dcd96858 (diff)
downloadzsh-9a17762b0cdf0112f54a86e7937118422ba65614.tar.gz
zsh-9a17762b0cdf0112f54a86e7937118422ba65614.zip
users/15217: use top-level status when redrawing prompt
Diffstat (limited to 'Src/Zle/zle_main.c')
-rw-r--r--Src/Zle/zle_main.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 16f98186f..5c6b65db3 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -84,6 +84,14 @@ int done;
int mark;
/*
+ * Status ($?) saved before function entry. This is the
+ * status we need to use in prompts.
+ */
+
+/**/
+static int pre_zle_status;
+
+/*
* Last character pressed.
*
* Depending how far we are with processing, the lastcharacter may
@@ -1129,6 +1137,12 @@ zleread(char **lp, char **rp, int flags, int context)
free(pptbuf);
return shingetline();
}
+ /*
+ * The current status is what we need if we are going
+ * to display a prompt. We'll remember it here for
+ * use further in.
+ */
+ pre_zle_status = lastval;
keytimeout = (time_t)getiparam("KEYTIMEOUT");
if (!shout) {
@@ -1756,6 +1770,14 @@ reexpandprompt(void)
static int reexpanding;
if (!reexpanding++) {
+ /*
+ * If we're displaying a status in the prompt, it
+ * needs to be the toplevel one, not the one from
+ * any status set within the local zle function.
+ */
+ int local_lastval = lastval;
+ lastval = pre_zle_status;
+
free(lpromptbuf);
lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL,
&pmpt_attr);
@@ -1763,6 +1785,7 @@ reexpandprompt(void)
free(rpromptbuf);
rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL,
&rpmpt_attr);
+ lastval = local_lastval;
}
reexpanding--;
}