diff --git a/ChangeLog b/ChangeLog index 30b8d7b2..3b7f5238 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-04-21 Benno Schulenberg + * src/browser.c (findnextfile): Save the settings of the global + case-sens, direction, and regexp flags, and restore them on exit. + And do this not in do_filesearch() but in findnextfile(), so that + it will also work for do_fileresearch(). + 2015-04-20 Benno Schulenberg * src/winio.c (need_horizontal_update, need_vertical_update): Fuse two identical functions into one: need_screen_update(). diff --git a/src/browser.c b/src/browser.c index 66d93a5a..39eedf6c 100644 --- a/src/browser.c +++ b/src/browser.c @@ -755,6 +755,16 @@ void findnextfile(const char *needle) const char *filetail = tail(filelist[looking_at]); /* The filename we display, minus the path. */ const char *rev_start = filetail, *found = NULL; + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ + + /* Save the settings of all flags. */ + memcpy(stash, flags, sizeof(flags)); + + /* Search forward, case insensitive and without regexes. */ + UNSET(BACKWARDS_SEARCH); + UNSET(CASE_SENSITIVE); + UNSET(USE_REGEXP); /* Step through each filename in the list until a match is found or * we've come back to the point where we started. */ @@ -797,6 +807,9 @@ void findnextfile(const char *needle) rev_start = filetail; } + /* Restore the settings of all flags. */ + memcpy(flags, stash, sizeof(flags)); + /* Select the one we've found. */ selected = looking_at; } @@ -804,10 +817,6 @@ void findnextfile(const char *needle) /* Search for a filename. */ void do_filesearch(void) { - UNSET(CASE_SENSITIVE); - UNSET(USE_REGEXP); - UNSET(BACKWARDS_SEARCH); - if (filesearch_init() != 0) { /* Cancelled, or a blank search string, or done something. */ bottombars(MBROWSER);