Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+4-1
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)