Skip to content

Commit 1713a00

Browse files
committed
psql: Fix %w length in PROMPT2 when PROMPT1 contains a newline.
The width of the invisible PROMPT2 must take into account, in order for user input to be aligned with the first line, that PROMPT1 can contain newlines. Author: Maxence Ahlouche Reviewed-by: Tom Lane Discussion: https://postgr.es/m/CAJeaomVyLSP_Wj%3D0FtYNTuoopWHyFarhUtYKDHs0HHv%2Bb%3DN9sA%40mail.gmail.com
1 parent c185a57 commit 1713a00

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/bin/psql/prompt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,10 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
373373
if (visible)
374374
{
375375
chwidth = PQdsplen(p, pset.encoding);
376-
if (chwidth > 0)
376+
377+
if (*p == '\n')
378+
last_prompt1_width = 0;
379+
else if (chwidth > 0)
377380
last_prompt1_width += chwidth;
378381
}
379382

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy