commit 813f9f72d0669ba882c3adb38ba24873e9e32b68
parent 0db28259ad2e8334548c79b9a260d730ea453557
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Feb 2016 16:42:30 +0000
Rebuilding the file list only when necessary, and not for each and every
cursor movement. This fixes Savannah bug #47133.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5638 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-13 Benno Schulenberg <bensberg@justemail.net>
+ * src/browser.c (do_browser, browser_refresh): Rebuild the file list
+ only when necessary, not for each and every cursor movement. This
+ fixes Savannah bug #47133.
+
GNU nano 2.5.2 - 2016.02.12
2016-02-11 Benno Schulenberg <bensberg@justemail.net>
diff --git a/src/browser.c b/src/browser.c
@@ -115,9 +115,20 @@ char *do_browser(char *path, DIR *dir)
/* The path we switch to at the "Go to Directory"
* prompt. */
- /* Display the file list if we don't have a key, or if the
- * selected file has changed, and set width in the process. */
- if (kbinput == ERR || old_selected != selected)
+#ifndef NANO_TINY
+ if (kbinput == KEY_WINCH) {
+ /* Rebuild the file list and sort it. */
+ browser_init(path_save, opendir(path_save));
+ qsort(filelist, filelist_len, sizeof(char *), diralphasort);
+
+ /* Make sure the selected file is within range. */
+ if (selected >= filelist_len)
+ selected = filelist_len - 1;
+ }
+#endif
+ /* Display (or redisplay) the file list if we don't have a key yet,
+ * or the list has changed, or the selected file has changed. */
+ if (kbinput == ERR || kbinput == KEY_WINCH || old_selected != selected)
browser_refresh();
old_selected = selected;
@@ -125,11 +136,8 @@ char *do_browser(char *path, DIR *dir)
kbinput = get_kbinput(edit);
#ifndef NANO_TINY
- if (kbinput == KEY_WINCH) {
- kbinput = ERR;
- curs_set(0);
+ if (kbinput == KEY_WINCH)
continue;
- }
#endif
#ifndef DISABLE_MOUSE
@@ -170,8 +178,8 @@ char *do_browser(char *path, DIR *dir)
} else if (func == do_help_void) {
#ifndef DISABLE_HELP
do_help_void();
- /* Perhaps the window dimensions have changed. */
- browser_refresh();
+ /* The window dimensions might have changed, so act as if. */
+ kbinput = KEY_WINCH;
curs_set(0);
#else
say_there_is_no_help();
@@ -548,14 +556,6 @@ void browser_refresh(void)
char *foo;
/* The additional information that we'll display about a file. */
- /* Perhaps window dimensions have changed; reinitialize the browser. */
- browser_init(path_save, opendir(path_save));
- qsort(filelist, filelist_len, sizeof(char *), diralphasort);
-
- /* Make sure the selected file is within range. */
- if (selected >= filelist_len)
- selected = filelist_len - 1;
-
titlebar(path_save);
blank_edit();