commit e7c28bcb66945868ea71c58e9f30fb0be259181a
parent 21207b47a048f6ebd58e6c482f2ef303ffb2f2a6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 10 Jul 2025 09:49:45 +0200
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.
Diffstat:
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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;