diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-02-10 13:20:00 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-02-10 13:21:26 +1300 |
commit | 1713a0013f909d9ce5dd43d234f1cd33d6a50854 (patch) | |
tree | 45f31e5bf4ddaea8cba36f47cc2a1246afbce3d5 | |
parent | c185a57753e64fe3ffc996ea18da8672b302a5a4 (diff) | |
download | postgresql-1713a0013f909d9ce5dd43d234f1cd33d6a50854.tar.gz postgresql-1713a0013f909d9ce5dd43d234f1cd33d6a50854.zip |
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
-rw-r--r-- | src/bin/psql/prompt.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 56202bd7681..26592b32872 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -373,7 +373,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; } |