summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarlon Richert <marlon.richert@gmail.com>2021-09-06 14:22:58 -0700
committerBart Schaefer <schaefer@ipost.com>2021-09-06 14:22:58 -0700
commit8ffcdc48248bff14f301a44525f954af5e7a8dee (patch)
treeb97ea09773950156e65aff3fe8e192c6f64db1f9
parenta675d058db7587eaf2f95da3e6d14fdacf01a7b0 (diff)
downloadzsh-8ffcdc48248bff14f301a44525f954af5e7a8dee.tar.gz
zsh-8ffcdc48248bff14f301a44525f954af5e7a8dee.zip
49292: Src/Zle/complist.c: turn off colors before clearing to end of line
-rw-r--r--ChangeLog3
-rw-r--r--Src/Zle/complist.c33
2 files changed, 22 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a6b68368..23388056b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* Marlon Richert: 49378: Src/parse.c: skip check for collision
of aliases and functions when NO_EXEC
+ * Marlon Richert: 49292: Src/Zle/complist.c: turn off colors
+ before clearing to end of line
+
* 49282: set $0 correctly when calling functions from hooks
* 49266: fix segfault on metacharacters in long job texts
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 353cb3562..0dc64db6a 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -603,6 +603,16 @@ zcoff(void)
zcputs(NULL, COL_NO);
}
+/* Clear to end of line, if possible and necessary. */
+static void
+cleareol()
+{
+ if (mlbeg >= 0 && tccan(TCCLEAREOL)) {
+ if (*last_cap)
+ zcoff(); /* If we used colors, prevent them from bleeding. */
+ tcout(TCCLEAREOL);
+ }
+}
static void
initiscol(void)
@@ -670,8 +680,7 @@ clprintfmt(char *p, int ml)
doiscol(i++);
cc++;
if (*p == '\n') {
- if (mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ cleareol();
cc = 0;
}
if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1)
@@ -693,8 +702,7 @@ clprintfmt(char *p, int ml)
!--mrestlines && (ask = asklistscroll(ml)))
return ask;
}
- if (mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ cleareol();
return 0;
}
@@ -1047,8 +1055,7 @@ compprintnl(int ml)
{
int ask;
- if (mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ cleareol();
putc('\n', shout);
if (mscroll && !--mrestlines && (ask = asklistscroll(ml)))
@@ -1263,8 +1270,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
if ((cc >= zterm_columns - 2 || cchar == ZWC('\n')) && stat)
dopr = 2;
if (cchar == ZWC('\n')) {
- if (dopr == 1 && mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ if (dopr == 1)
+ cleareol();
l += 1 + ((cc - 1) / zterm_columns);
cc = 0;
}
@@ -1306,8 +1313,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
if (dopr) {
if (!(cc % zterm_columns))
fputs(" \010", shout);
- if (mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ cleareol();
}
if (stat && n)
mfirstl = -1;
@@ -1338,8 +1344,8 @@ compzputs(char const *s, int ml)
c = *s;
s++;
putc(c, shout);
- if (c == '\n' && mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ if (c == '\n')
+ cleareol();
if (mscroll && (++col == zterm_columns || c == '\n')) {
ml++;
if (!--mrestlines && (ask = asklistscroll(ml)))
@@ -1692,8 +1698,7 @@ compprintlist(int showall)
lastlistlen = listdat.nlines;
} else if ((nl = listdat.nlines + nlnct - 1) < zterm_lines) {
- if (mlbeg >= 0 && tccan(TCCLEAREOL))
- tcout(TCCLEAREOL);
+ cleareol();
tcmultout(TCUP, TCMULTUP, nl);
showinglist = -1;