From e7c28bcb66945868ea71c58e9f30fb0be259181a Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 10 Jul 2025 09:49:45 +0200 Subject: [PATCH] browser: redo the layout only when an actual resize occurred This improves upon the previous commit. This fixes https://savannah.gnu.org/bugs/?67294 in a better way. --- src/browser.c | 7 +++++-- src/global.c | 2 ++ src/nano.c | 1 + src/prototypes.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/browser.c b/src/browser.c index 8e4aa204..82a3dd39 100644 --- a/src/browser.c +++ b/src/browser.c @@ -421,6 +421,10 @@ char *browse(char *path) dir = NULL; } +#ifndef NANO_TINY + resized_for_browser = FALSE; +#endif + /* If something was selected before, reselect it; * otherwise, just select the first item (..). */ if (present_name != NULL) { @@ -644,8 +648,7 @@ char *browse(char *path) rearrange: #ifndef NANO_TINY /* If the terminal resized (or might have), refresh the file list. */ - if (kbinput == THE_WINDOW_RESIZED || function == do_help || function == goto_dir || - function == do_search_backward || function == do_search_forward) { + if (kbinput == THE_WINDOW_RESIZED || resized_for_browser) { /* Remember the selected file, to be able to reselect it. */ present_name = copy_of(filelist[selected]); goto read_directory_contents; diff --git a/src/global.c b/src/global.c index a97ddf6a..2ff88d5b 100644 --- a/src/global.c +++ b/src/global.c @@ -30,6 +30,8 @@ #ifndef NANO_TINY volatile sig_atomic_t the_window_resized = FALSE; /* Set to TRUE by the handler whenever a SIGWINCH occurs. */ +volatile sig_atomic_t resized_for_browser = FALSE; + /* Same as above, but used by the file browser. */ #endif bool on_a_vt = FALSE; diff --git a/src/nano.c b/src/nano.c index 12748b76..9cf3dfbe 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1049,6 +1049,7 @@ void handle_sigwinch(int signal) { /* Let the input routine know that a SIGWINCH has occurred. */ the_window_resized = TRUE; + resized_for_browser = TRUE; } /* Reinitialize and redraw the screen completely. */ diff --git a/src/prototypes.h b/src/prototypes.h index 66053058..e1cd8f61 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -24,6 +24,7 @@ #ifndef NANO_TINY extern volatile sig_atomic_t the_window_resized; +extern volatile sig_atomic_t resized_for_browser; #endif extern bool on_a_vt;