summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authordana <dana@dana.is>2019-04-18 20:35:55 +0200
committerMikael Magnusson <mikachu@gmail.com>2019-04-18 20:54:19 +0200
commit64d13738357c9b9c212adbe17f271716abbcf6ea (patch)
treea356769206c3c3725d46fac212e8faef074b3913 /Src
parent11ff9b3db96fad0fe51fd7b1a49a6c733c7d9d07 (diff)
downloadzsh-64d13738357c9b9c212adbe17f271716abbcf6ea.tar.gz
zsh-64d13738357c9b9c212adbe17f271716abbcf6ea.zip
43288: fix line-broken prompts
Without re-breaking the case where a newline character lands in column 0.
Diffstat (limited to 'Src')
-rw-r--r--Src/prompt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index f2b3f161e..e8d50d161 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1075,10 +1075,10 @@ putstr(int d)
mod_export void
countprompt(char *str, int *wp, int *hp, int overf)
{
- int w = 0, h = 1;
+ int w = 0, h = 1, multi = 0;
int s = 1;
#ifdef MULTIBYTE_SUPPORT
- int wcw, multi = 0;
+ int wcw;
char inchar;
mbstate_t mbs;
wchar_t wc;
@@ -1087,7 +1087,12 @@ countprompt(char *str, int *wp, int *hp, int overf)
#endif
for (; *str; str++) {
- if (w > zterm_columns && overf >= 0) {
+ /*
+ * Avoid double-incrementing the height when there's a newline in the
+ * prompt and the line it terminates takes up exactly the width of the
+ * terminal
+ */
+ if (w >= zterm_columns && overf >= 0 && !multi && *str != '\n') {
w = 0;
h++;
}