commit 491cf173aad247299622796775feea580a8f9b13 (HEAD -> refs/heads/patch_psql_prompt)
Author: Maxence Ahlouche <maxence.ahlouche@gmail.com>
Date:   Wed Nov 27 16:21:35 2019 +0100

    Fix %w length in PROMPT2 when PROMPT1 contains a newline, in psql.
    
    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.

diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 41c6f21ecf..24efb8f686 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -379,7 +379,10 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
 				if (visible)
 				{
 					chwidth = PQdsplen(p, pset.encoding);
-					if (chwidth > 0)
+
+					if (*p == '\n')
+						last_prompt1_width = 0;
+					else if (chwidth > 0)
 						last_prompt1_width += chwidth;
 				}
 
