From: Benno Schulenberg Date: Sun, 12 Apr 2015 08:31:53 +0000 (+0000) Subject: Stopping M-\ and M-/ in the WhereisFile menu from doing also an X-Git-Tag: v2.4.1~7 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=99d2358510954fef23a9e382058278f531285df5;p=nano.git Stopping M-\ and M-/ in the WhereisFile menu from doing also an unrequested search after having performed their function. Fixes Savannah bug #44790. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5190 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 764d3f5f..4be23837 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-04-12 Benno Schulenberg + * src/browser.c (filesearch_init): Stop M-\ and M-/ in WhereisFile + menu (reached via ^R ^T ^W) from doing also an unrequested search + after having performed their function. Fixes Savannah bug #44790. + 2015-04-11 Benno Schulenberg * src/search.c (do_replace_loop): Do not split off the marked region into a separate partition, but do the replacings in the current one, diff --git a/src/browser.c b/src/browser.c index 9db173d3..bdd108c6 100644 --- a/src/browser.c +++ b/src/browser.c @@ -703,7 +703,7 @@ void browser_select_dirname(const char *needle) * program. */ int filesearch_init(void) { - int i = 0; + int input; char *buf; static char *backupstring = NULL; /* The search string we'll be using. */ @@ -727,7 +727,7 @@ int filesearch_init(void) buf = mallocstrcpy(NULL, ""); /* This is now one simple call. It just does a lot. */ - i = do_prompt(FALSE, + input = do_prompt(FALSE, #ifndef DISABLE_TABCOMP TRUE, #endif @@ -743,14 +743,16 @@ int filesearch_init(void) free(backupstring); backupstring = NULL; - /* Cancel any search, or just return with no previous search. */ - if (i == -1 || (i < 0 && *last_search == '\0') || (i == 0 && - *answer == '\0')) { + /* If only Enter was pressed but we have a previous string, it's okay. */ + if (input == -2 && *last_search != '\0') + return 0; + + /* Otherwise negative inputs are a bailout. */ + if (input < 0) statusbar(_("Cancelled")); - return -1; - } - return 0; + /* Zero is good; positive values mean some function was run. */ + return input; } /* Look for the given needle in the list of files. */ @@ -817,7 +819,7 @@ void do_filesearch(void) UNSET(BACKWARDS_SEARCH); if (filesearch_init() != 0) { - /* Cancelled or a blank search string. */ + /* Cancelled, or a blank search string, or done something. */ bottombars(MBROWSER); return; }