From 6062a040e12a4c7488a0809fa7f6c85b0ecf4799 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 28 Jun 2015 06:32:56 +0000 Subject: [PATCH] Limiting the selected file to the available ones in the list. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5273 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/browser.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 547efcca..46505e7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-06-28 Benno Schulenberg + * src/browser.c (browser_refresh): Limit the selected file to the + available ones in the list -- after a refresh the number may have + decreased. This fixes Savannah bug #45424. + 2015-06-27 Benno Schulenberg * src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when it really tried to delete the final, magic newline. diff --git a/src/browser.c b/src/browser.c index 98beef1e..3191e557 100644 --- a/src/browser.c +++ b/src/browser.c @@ -565,6 +565,10 @@ void browser_refresh(void) 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(); -- 2.39.5