From: dana <dana@dana.is>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Guillaume Chazarain <guichaz@gmail.com>,
zsh-workers@zsh.org, warepire.ml@gmail.com
Subject: Re: "off by one fix in multiple prompts" breaks multiline prompt
Date: Mon, 13 Aug 2018 16:29:24 -0500 [thread overview]
Message-ID: <383CC796-865C-4774-A9C2-AD44997784B4@dana.is> (raw)
In-Reply-To: <3F00E10A-6A65-4201-A4E2-2A29929111C1@dana.is>
On 13 Aug 2018, at 09:19, dana <dana@dana.is> wrote:
>Looking at that function again, i wonder if the original problem was actually
>related to the fact that it compares the current column count (and
>potentially increments the height) before checking whether the current character
>is a new-line?
I think that was in fact the problem. So if we revert the previous change, and
then add an additional check for a last-column new-line, we end up with
something like the attached. This seems to fix both the original issue and the
new one for me, but obviously further testing would be nice
dana
diff --git a/Src/prompt.c b/Src/prompt.c
index 959ed8e3d..1a3765407 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1074,10 +1074,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;
@@ -1086,7 +1086,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++;
}
next prev parent reply other threads:[~2018-08-13 21:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180810072702epcas5p4ecaa5cffa5dc7668e2b2aa3a30824f36@epcas5p4.samsung.com>
2018-08-10 7:26 ` Guillaume Chazarain
2018-08-13 8:42 ` Peter Stephenson
2018-08-13 11:22 ` Guillaume Chazarain
2018-08-13 11:36 ` Peter Stephenson
2018-08-13 11:42 ` Guillaume Chazarain
2018-08-13 12:58 ` Peter Stephenson
2018-08-13 14:19 ` dana
2018-08-13 18:34 ` Guillaume Chazarain
2018-08-13 21:29 ` dana [this message]
2018-08-13 21:45 ` Bart Schaefer
2018-08-13 22:44 ` dana
2018-08-14 8:30 ` Peter Stephenson
2018-08-14 6:41 ` Guillaume Chazarain
[not found] ` <20180813123639.5899f64e@camnpupstephen.cam.scsc.local>
2018-08-13 11:40 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=383CC796-865C-4774-A9C2-AD44997784B4@dana.is \
--to=dana@dana.is \
--cc=guichaz@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=warepire.ml@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).