Skip to content

Commit

Permalink
Reload last search string if any.
Browse files Browse the repository at this point in the history
Signed-off-by: Liu Hao <lh_mouse@126.com>
  • Loading branch information
lhmouse committed Dec 21, 2024
1 parent 3729731 commit 5b7ea33
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ void search_init(bool replacing, bool retain_answer)
char *thedefault;
/* What will be searched for when the user types just <Enter>. */

#ifdef ENABLE_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

/* If something was searched for earlier, include it in the prompt. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
Expand Down

0 comments on commit 5b7ea33

Please sign in to comment.