Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "off by one fix in multiple prompts" breaks multiline prompt
- X-seq: zsh-workers 43288
- From: dana <dana@xxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: "off by one fix in multiple prompts" breaks multiline prompt
- Date: Mon, 13 Aug 2018 16:29:24 -0500
- Cc: Guillaume Chazarain <guichaz@xxxxxxxxx>, zsh-workers@xxxxxxx, warepire.ml@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oV17nBaJdtxXhQfHHJSoWdzpdx3NIPu2f4+JK1vyElo=; b=HBWgJ4wtsaTyWkVsS5eC0sPrmtR/ciXhbrepgELDSeAV4EDDrenD68aGED8MsN61t2 kkiZG8jW7YkaQCd/Na9grxSLOTc6sDqaO7iuVfuMdZ3sfqB6pKmGNBpcOcPPt6G2wGw1 BDe0ixE/oGQM00aPAQ6iW1PcQRyR4APz2tsFchJ0WygHLspwONzPDelreTR7CPk9GoxA pLewnz4ftJMGLbhK4llpUex0+97IIQwtWXdzA6/F89nEUyduHWkAtapU0gsXjOmFfzrk qB5xvGdlFPiHL98/ZG0R/Une8LNpxteCqVwxm5mqETgNJJcrTgQaf1fXdV3fx4ho9t4q ro2w==
- In-reply-to: <3F00E10A-6A65-4201-A4E2-2A29929111C1@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180810072702epcas5p4ecaa5cffa5dc7668e2b2aa3a30824f36@epcas5p4.samsung.com> <CAA879TMRSWDSkqHP206-JLaJ8F4U=18DYU1CpCwCQ4iWMu_4Tg@mail.gmail.com> <20180813084255eucas1p102bc21872ad72a2cd049d8d9db2f0e86~KZResIryo0309103091eucas1p10@eucas1p1.samsung.com> <CAA879TPfqJbR1vwYfbRTCWoqkC-iH7pXHSwGYUzqOj8CT95xPg@mail.gmail.com> <20180813113640eucas1p19d52c9c05089626f375a00c5115aef32~KbpML4Mzp0510505105eucas1p1P@eucas1p1.samsung.com> <CAA879TOk3wqsY96dipo=gvFeN0OXTC0ei9i0xRsSyYyVmFG2rg@mail.gmail.com> <20180813125810eucas1p181a58cb55dc815863d6d81e1cd629d71~KcwV9B7ZD1627716277eucas1p1o@eucas1p1.samsung.com> <3F00E10A-6A65-4201-A4E2-2A29929111C1@dana.is>
On 13 Aug 2018, at 09:19, dana <dana@xxxxxxx> 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++;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author