From 5df47bfef68284bcb4608067c23437f374fda823 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 13 Jul 2017 10:55:02 +0200
Subject: [PATCH] display: avoid a jumpy cursor by redrawing bottom bars only
 when needed

The help lines need to be redrawn one step after a justification
(whether it has been undone or not, to replace "Unjustify" with
"Uncut" again for ^U), and after switching buffers (to update a
possibly changed tag for ^T).

This fixes https://savannah.gnu.org/bugs/?51455.
---
 src/files.c | 11 ++++++++---
 src/nano.c  |  3 ++-
 src/text.c  |  3 ++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/files.c b/src/files.c
index 529ed362..f56b9725 100644
--- a/src/files.c
+++ b/src/files.c
@@ -631,9 +631,14 @@ void switch_to_prevnext_buffer(bool to_next)
     /* Update titlebar and multiline info to match the current buffer. */
     prepare_for_display();
 
+    if (inhelp)
+	return;
+
+    /* Ensure that the main loop will redraw the help lines. */
+    currmenu = MMOST;
+
     /* Indicate the switch on the statusbar. */
-    if (!inhelp)
-	statusline(HUSH, _("Switched to %s"),
+    statusline(HUSH, _("Switched to %s"),
 			((openfile->filename[0] == '\0') ?
 			_("New Buffer") : openfile->filename));
 
@@ -677,7 +682,7 @@ bool close_buffer(void)
     /* Close the file buffer we had open before. */
     unlink_opennode(openfile->prev);
 
-    /* If only one buffer is open now, show Exit in the help lines. */
+    /* If now just one buffer remains open, show "Exit" in the help lines. */
     if (openfile == openfile->next)
 	exitfunc->desc = exit_tag;
 
diff --git a/src/nano.c b/src/nano.c
index f2a7edbb..ac2e56bf 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2613,7 +2613,8 @@ int main(int argc, char **argv)
 	}
 #endif
 
-	display_main_list();
+	if (currmenu != MMAIN)
+	    display_main_list();
 
 	lastmessage = HUSH;
 	as_an_at = TRUE;
diff --git a/src/text.c b/src/text.c
index c2b1fa3e..6569059f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -2511,8 +2511,9 @@ void do_justify(bool full_justify)
     blank_statusbar();
     wnoutrefresh(bottomwin);
 
-    /* Show "Uncut" again in the help lines. */
+    /* Show "Uncut" again in the help lines, and force their redrawing. */
     uncutfunc->desc = uncut_tag;
+    currmenu = MMOST;
 }
 
 /* Justify the current paragraph. */
-- 
GitLab