From 11e00410bd19a60422fc2b4da42a0ff8a2fc6210 Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Tue, 5 Sep 2017 15:35:11 +0800 Subject: [PATCH 5/6] Reload last search string if any. --- src/search.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/search.c b/src/search.c index 43e816d8..771e2950 100644 --- a/src/search.c +++ b/src/search.c @@ -112,6 +112,13 @@ int search_init(bool replacing, bool use_answer) return 0; } +#ifndef DISABLE_HISTORIES + /* If nothing was searched for yet during this run of nano, but + * there is a search history, take the most recent item. */ + if (*last_search == '\0' && searchbot->prev != NULL) + last_search = mallocstrcpy(last_search, searchbot->prev->data); +#endif + /* We display the search prompt below. If the user types a partial * search string and then Replace or a toggle, we will return to * do_search() or do_replace() and be called again. In that case, -- 2.15.0