Storing always the last-typed string, also when it's an invalid regex.

This fixes Savannah bug #47440.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5742 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2016-03-19 16:19:44 +00:00
parent e753cd1c38
commit a6740ba3fd
2 changed files with 13 additions and 23 deletions

View File

@ -1,3 +1,7 @@
2016-03-19 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (search_init): Always remember the last typed string,
also when it's an invalid regex. This fixes Savannah bug #47440.
2016-03-17 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_research): Use the Search key bindings also during
a Re-search, to enable cancelling. This fixes Savannah bug #47159.

View File

@ -206,10 +206,14 @@ int search_init(bool replacing, bool use_answer)
if (i == -2 || i == 0 ) {
#ifdef HAVE_REGEX_H
/* Use last_search if answer is an empty string, or
* answer if it isn't. */
if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ?
last_search : answer))
/* If an answer was given, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifndef DISABLE_HISTORIES
update_history(&search_history, answer);
#endif
}
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
#endif
;
@ -431,18 +435,9 @@ void do_search(void)
if (i != 0)
return;
/* If answer is now "", copy last_search into answer. */
/* If answer is empty, use what was last searched for. */
if (*answer == '\0')
answer = mallocstrcpy(answer, last_search);
else
last_search = mallocstrcpy(last_search, answer);
#ifndef DISABLE_HISTORIES
/* If answer is not "", add this search string to the search history
* list. */
if (answer[0] != '\0')
update_history(&search_history, answer);
#endif
findnextstr_wrap_reset();
didfind = findnextstr(
@ -850,15 +845,6 @@ void do_replace(void)
if (i != 0)
return;
/* If answer is not "", add answer to the search history list and
* copy answer into last_search. */
if (answer[0] != '\0') {
#ifndef DISABLE_HISTORIES
update_history(&search_history, answer);
#endif
last_search = mallocstrcpy(last_search, answer);
}
last_replace = mallocstrcpy(last_replace, "");
i = do_prompt(FALSE,