From d865d7ac8ff15b4de4d1f1682def0978b57d68fa Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 5 Feb 2018 12:35:53 +0100 Subject: [PATCH] search: clear the existing answer when starting a new search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When doing for example: ^W xx ^R ^C ^W, the "xx" would again be shown after the prompt. This is wrong -- when starting a new search, the current answer should be empty. Reported-by: Marco Diego Aurélio Mesquita --- src/search.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/search.c b/src/search.c index 2d5e2cc1..894d4ab6 100644 --- a/src/search.c +++ b/src/search.c @@ -99,8 +99,7 @@ void search_init(bool replacing, bool keep_the_answer) static char *sofar = NULL; /* What the user has typed so far, before toggling something. */ - if (keep_the_answer) - sofar = mallocstrcpy(sofar, answer); + sofar = mallocstrcpy(sofar, keep_the_answer ? answer : ""); /* If something was searched for earlier, include it in the prompt. */ if (*last_search != '\0') {