summaryrefslogtreecommitdiff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2020-02-14 01:58:20 +0100
committerAxel Beckert <abe@deuxchevaux.org>2020-02-14 01:58:20 +0100
commitbfc5d42735c1660263904ec5254cccf539a0a458 (patch)
tree9bbb81b4a53941427e6f9e65ae55027d9108df8c /Src/prompt.c
parent74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff)
parent643de931640e01aa246723d2038328ef33737965 (diff)
downloadzsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz
zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index f2b3f161e..b65bfb86b 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -163,7 +163,7 @@ promptpath(char *p, int npath, int tilde)
*
* txtchangep gives an integer controlling the attributes of
* the prompt. This is for use in zle to maintain the attributes
- * consistenly. Other parts of the shell should not need to use it.
+ * consistently. Other parts of the shell should not need to use it.
*/
/**/
@@ -1075,10 +1075,9 @@ 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, wcw = 0;
int s = 1;
#ifdef MULTIBYTE_SUPPORT
- int wcw, multi = 0;
char inchar;
mbstate_t mbs;
wchar_t wc;
@@ -1087,10 +1086,28 @@ countprompt(char *str, int *wp, int *hp, int overf)
#endif
for (; *str; str++) {
- if (w > zterm_columns && overf >= 0) {
- w = 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
+ */
+ while (w > zterm_columns && overf >= 0 && !multi) {
h++;
+ if (wcw) {
+ /*
+ * Wide characters don't get split off. They move to the
+ * next line if there is not enough space.
+ */
+ w = wcw;
+ break;
+ } else {
+ /*
+ * Tabs overflow to the next line as if they were made of spaces.
+ */
+ w -= zterm_columns;
+ }
}
+ wcw = 0;
/*
* Input string should be metafied, so tokens in it should
* be real tokens, even if there are multibyte characters.
@@ -1171,12 +1188,19 @@ countprompt(char *str, int *wp, int *hp, int overf)
* This isn't easy to handle generally; just assume there's no
* output.
*/
- if(w >= zterm_columns && overf >= 0) {
- if (!overf || w > zterm_columns) {
- w = 0;
- h++;
+ while (w > zterm_columns && overf >= 0) {
+ h++;
+ if (wcw) {
+ w = wcw;
+ break;
+ } else {
+ w -= zterm_columns;
}
}
+ if (w == zterm_columns && overf == 0) {
+ w = 0;
+ h++;
+ }
if(wp)
*wp = w;
if(hp)