Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] init: don't reset ZLE_RPROMPT_INDENT on term init



currently, rprompt_indent gets reset to 1 whenever the terminal is
re-initialised, so if the user ever touches TERM, even locally in a
function or in a pre-command assignment before a built-in, it will
revert their ZLE_RPROMPT_INDENT

imo we should leave it alone if the user has explicitly set it

dana


diff --git a/Src/init.c b/Src/init.c
index f36bc332b..d2b97daff 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -882,7 +882,10 @@ init_term(void)
 	    tcstr[TCCLEARSCREEN] = ztrdup("\14");
 	    tclen[TCCLEARSCREEN] = 1;
 	}
-	rprompt_indent = 1; /* If you change this, update rprompt_indent_unsetfn() */
+
+	// don't touch this if it's been set explicitly by the user
+	if (!getsparam("ZLE_RPROMPT_INDENT"))
+	    rprompt_indent = 1; /* If you change this, update rprompt_indent_unsetfn() */
 	/* The following is an attempt at a heuristic,
 	 * but it fails in some cases */
 	/* int hasbw = tgetflag("bw"); */
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index d2fa63535..b80564db2 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -3104,3 +3104,18 @@ F:output ignorable as long as not an error
 >47 47
 >74 74
 >74 74
+
+  $ZTST_testdir/../Src/zsh -fic '
+    echo ${ZLE_RPROMPT_INDENT-unset}
+    for 1 in "" 0 1 2; do (
+      ZLE_RPROMPT_INDENT=$1
+      () { local TERM=dumb }
+      echo ${ZLE_RPROMPT_INDENT-unset}
+    ); done
+  '
+0:ZLE_RPROMPT_INDENT value
+>unset
+>0
+>0
+>1
+>2




Messages sorted by: Reverse Date, Date, Thread, Author