diff options
author | dana <dana@dana.is> | 2019-04-18 20:35:55 +0200 |
---|---|---|
committer | Mikael Magnusson <mikachu@gmail.com> | 2019-04-18 20:54:19 +0200 |
commit | 64d13738357c9b9c212adbe17f271716abbcf6ea (patch) | |
tree | a356769206c3c3725d46fac212e8faef074b3913 | |
parent | 11ff9b3db96fad0fe51fd7b1a49a6c733c7d9d07 (diff) | |
download | zsh-64d13738357c9b9c212adbe17f271716abbcf6ea.tar.gz zsh-64d13738357c9b9c212adbe17f271716abbcf6ea.tar.xz zsh-64d13738357c9b9c212adbe17f271716abbcf6ea.zip |
43288: fix line-broken prompts
Without re-breaking the case where a newline character lands in column 0.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Src/prompt.c | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index ab477c183..9e1d6ec1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-04-18 Mikael Magnusson <mikachu@gmail.com> + + * dana: 43288: Src/prompt.c: fix line-broken prompts + 2019-04-12 dana <dana@dana.is> * unposted: NEWS: Document recent feature additions 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++; } |