From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24350 invoked by alias); 13 Aug 2018 21:29:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43288 Received: (qmail 272 invoked by uid 1010); 13 Aug 2018 21:29:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-it0-f45.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.214.45):SA:0(-1.9/5.0):. Processed in 1.070429 secs); 13 Aug 2018 21:29:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oV17nBaJdtxXhQfHHJSoWdzpdx3NIPu2f4+JK1vyElo=; b=jD4PSU3IRtLP9IbgZnDTcYSCn1jASnNqClQ1wHGHUiyd0JBPaDm+Rbv3HlQlM7C3Zt VHRI91pkILhrPBRflUmlNK6gRNDfi68BhlcbrNq04FrDoNrjfD5W7HPIybLi7Qwf51Wf fsoJqF5KNY/9E87jSuM7OrF03HCzBCjkCkeCJJg1qOP3T1VkfC71xAHhmWM4UboGLrNd nsYFxs95zhs/X0KaL4rxRJgPA2tvk7ZOAf7S4I/uCaDXIHknZkMQ+gRr0hXvBxs+qq/I J+5us/LsvTm1cnsYR3nNM+RLspaIZC90J41cusnFq0R1RFD89OXUR1gdHm0DcRtawu0X A2TQ== X-Gm-Message-State: AOUpUlFGKvMkJDTqtLOVKGn0kI9+NLKlQK7DpnbDTFnkNVy7Ek6SwL02 CYSsKyB1DwxBcNyD1t8ZOucCsw== X-Google-Smtp-Source: AA+uWPyAZrlsZ58rr08b5POgZM6Dz+OnBPq9UVUa4m0O7Si1kbhaVOZms4H87+e01g+8fgcBQKznLg== X-Received: by 2002:a24:b101:: with SMTP id o1-v6mr11820070itf.121.1534195765774; Mon, 13 Aug 2018 14:29:25 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\)) Subject: Re: "off by one fix in multiple prompts" breaks multiline prompt From: dana In-Reply-To: <3F00E10A-6A65-4201-A4E2-2A29929111C1@dana.is> Date: Mon, 13 Aug 2018 16:29:24 -0500 Cc: Guillaume Chazarain , zsh-workers@zsh.org, warepire.ml@gmail.com Content-Transfer-Encoding: quoted-printable Message-Id: <383CC796-865C-4774-A9C2-AD44997784B4@dana.is> References: <20180813084255eucas1p102bc21872ad72a2cd049d8d9db2f0e86~KZResIryo0309103091eucas1p10@eucas1p1.samsung.com> <20180813113640eucas1p19d52c9c05089626f375a00c5115aef32~KbpML4Mzp0510505105eucas1p1P@eucas1p1.samsung.com> <20180813125810eucas1p181a58cb55dc815863d6d81e1cd629d71~KcwV9B7ZD1627716277eucas1p1o@eucas1p1.samsung.com> <3F00E10A-6A65-4201-A4E2-2A29929111C1@dana.is> To: Peter Stephenson X-Mailer: Apple Mail (2.3445.8.2) On 13 Aug 2018, at 09:19, dana 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 =3D 0, h =3D 1; + int w =3D 0, h =3D 1, multi =3D 0; int s =3D 1; #ifdef MULTIBYTE_SUPPORT - int wcw, multi =3D 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 =20 for (; *str; str++) { - if (w > zterm_columns && overf >=3D 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 >=3D zterm_columns && overf >=3D 0 && !multi && *str !=3D = '\n') { w =3D 0; h++; }