From 64d13738357c9b9c212adbe17f271716abbcf6ea Mon Sep 17 00:00:00 2001 From: dana Date: Thu, 18 Apr 2019 20:35:55 +0200 Subject: 43288: fix line-broken prompts Without re-breaking the case where a newline character lands in column 0. --- Src/prompt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Src') 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++; } -- cgit 1.4.1