diff --git a/src/browser.c b/src/browser.c index e688e4d..f0268a4 100644 --- a/src/browser.c +++ b/src/browser.c @@ -65,7 +65,7 @@ char *do_browser(char *path, DIR *dir) UNSET(CONST_UPDATE); change_browser_directory: - /* We go here after we select a new directory. */ + /* We go here after we select a new directory or when we refresh. */ /* Start with no key pressed. */ kbinput = ERR; @@ -176,6 +176,17 @@ char *do_browser(char *path, DIR *dir) total_redraw(); /* Simulate a window resize. */ kbinput = KEY_WINCH; + + /* Keep the selection even if number of file in cwd changes. */ + prev_dir = strdup(filelist[selected]); + dir = opendir(path); + if (dir == NULL) { + statusbar(_("Error reading %s: %s"), + filelist[selected], strerror(errno)); + beep(); + continue; + } + goto change_browser_directory; } else if (func == do_help_void) { #ifndef DISABLE_HELP do_help_void(); @@ -684,6 +695,11 @@ void browser_select_dirname(const char *needle) break; } } + + /* Do a conspicuous change when file that was supposed to found + * is not found. */ + if (looking_at == filelist_len) + --selected; } /* Set up the system variables for a filename search. Return -1 or -2 if