From a4132e2e64e2777fe61a437fb4fa398837dca01a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 12 Nov 2016 17:59:28 +0100
Subject: [PATCH] screen: do a refresh before changing the value of 'focusing'

This fixes https://savannah.gnu.org/bugs/?49530.
---
 src/nano.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index c9751120..c2a90bc3 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2721,6 +2721,14 @@ int main(int argc, char **argv)
 	if (currmenu != MMAIN)
 	    display_main_list();
 
+	/* Refresh either just the cursor or the entire edit window. */
+	if (!refresh_needed) {
+	    reset_cursor();
+	    curs_set(1);
+	    wnoutrefresh(edit);
+	} else
+	    edit_refresh();
+
 	focusing = TRUE;
 	lastmessage = HUSH;
 
@@ -2733,15 +2741,6 @@ int main(int argc, char **argv)
 	/* Forget any earlier statusbar x position. */
 	reinit_statusbar_x();
 
-	/* Refresh either the entire edit window or just the cursor. */
-	if (refresh_needed)
-	    edit_refresh();
-	else {
-	    reset_cursor();
-	    curs_set(1);
-	    wnoutrefresh(edit);
-	}
-
 	/* Read in and interpret keystrokes. */
 	do_input(TRUE);
     }
-- 
GitLab