From c9482bcd2b627f1ae7366e6f6508617af1e5c59c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 21 May 2020 09:12:33 +0200 Subject: [PATCH] display: do not try to draw content when there is no open buffer yet Commit b63c90bf avoided creating an empty buffer before asking the yes-no question when encountering a lock file at startup, but the SIGWINCH code still expected to have an open buffer whose contents to show. This fix also has the pleasant effect that, when resizing the screen at the lock-file yes-no prompt, the title bar doesn't suddenly appear. This fixes https://savannah.gnu.org/bugs/?58414. Reported-by: Liu Hao Bug existed since version 4.9, commit b63c90bf. --- src/nano.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nano.c b/src/nano.c index 3dfc5e12..1b85c49f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1039,18 +1039,20 @@ void regenerate_screen(void) #endif editwincols = COLS - margin; - /* Ensure that firstcolumn is the starting column of its chunk. */ - ensure_firstcolumn_is_aligned(); - /* Do as the website suggests: leave and immediately reenter curses mode. */ endwin(); doupdate(); - /* Put the terminal in the desired state again, recreate the subwindows - * with their (new) sizes, and redraw the contents of these windows. */ + /* Put the terminal in the desired state again, and + * recreate the subwindows with their (new) sizes. */ terminal_init(); window_init(); - total_refresh(); + + /* If we have an open buffer, redraw the contents of the subwindows. */ + if (openfile) { + ensure_firstcolumn_is_aligned(); + total_refresh(); + } } /* Handle the global toggle specified in flag. */