From 50616148b0aa323c50c0904315e2907cd740517f Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 25 Aug 2016 20:02:35 +0200
Subject: [PATCH] prompt: recompose the statusbar text whenever the window size
 changes

This fixes https://savannah.gnu.org/bugs/?48796.
---
 src/prompt.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/prompt.c b/src/prompt.c
index 16d21d01..58824878 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -563,10 +563,12 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
 	assert(statusbar_x <= strlen(answer));
 
 #ifndef NANO_TINY
+	/* If the window size changed, go reformat the prompt string. */
 	if (kbinput == KEY_WINCH) {
 	    refresh_func();
-	    update_the_statusbar();
-	    continue;
+	    *actual = KEY_WINCH;
+	    free(magichistory);
+	    return NULL;
 	}
 #endif
 	func = func_from_key(&kbinput);
@@ -706,7 +708,7 @@ int do_prompt(bool allow_tabs,
 	void (*refresh_func)(void), const char *msg, ...)
 {
     va_list ap;
-    int retval;
+    int retval = KEY_WINCH;
     functionptrtype func;
 #ifndef DISABLE_TABCOMP
     bool listed = FALSE;
@@ -717,6 +719,7 @@ int do_prompt(bool allow_tabs,
 
     bottombars(menu);
 
+    while (retval == KEY_WINCH) {
     prompt = charalloc((COLS * mb_cur_max()) + 1);
     va_start(ap, msg);
     vsnprintf(prompt, COLS * mb_cur_max(), msg, ap);
@@ -735,6 +738,7 @@ int do_prompt(bool allow_tabs,
 
     free(prompt);
     prompt = NULL;
+    }
 
     /* If we're done with this prompt, restore the x position to what
      * it was at a possible previous prompt. */
-- 
GitLab