about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/prompt.c11
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ab477c183..9e1d6ec1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-04-18  Mikael Magnusson  <mikachu@gmail.com>
+
+	* dana: 43288: Src/prompt.c: fix line-broken prompts
+
 2019-04-12  dana  <dana@dana.is>
 
 	* unposted: NEWS: Document recent feature additions
diff --git a/Src/prompt.c b/Src/prompt.c
index f2b3f161e..e8d50d161 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1075,10 +1075,10 @@ putstr(int d)
 mod_export void
 countprompt(char *str, int *wp, int *hp, int overf)
 {
-    int w = 0, h = 1;
+    int w = 0, h = 1, multi = 0;
     int s = 1;
 #ifdef MULTIBYTE_SUPPORT
-    int wcw, multi = 0;
+    int wcw;
     char inchar;
     mbstate_t mbs;
     wchar_t wc;
@@ -1087,7 +1087,12 @@ countprompt(char *str, int *wp, int *hp, int overf)
 #endif
 
     for (; *str; str++) {
-	if (w > zterm_columns && overf >= 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 >= zterm_columns && overf >= 0 && !multi && *str != '\n') {
 	    w = 0;
 	    h++;
 	}