From 3d6dcb956804d3e9e5ed12597596478180c35afb Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 9 Oct 2021 12:12:05 +0200 Subject: [PATCH] prompt: begin at bottom of history list when at secondary prompt Whenever invoking a search prompt, calling up historical search items should start with the newest item. This fixes https://savannah.gnu.org/bugs/?61316. Bug existed since version 2.8.2, since help texts became searchable. --- src/prompt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/prompt.c b/src/prompt.c index 9e762070..04c606d6 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -456,6 +456,9 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, size_t fragment_length = 0; /* The length of the fragment that the user tries to tab complete. */ #endif + + if (history_list != NULL) + history_reset(*history_list); #endif /* ENABLE_HISTORIES */ if (typing_x > strlen(answer)) @@ -563,7 +566,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, } #ifdef ENABLE_HISTORIES - /* Set the current position in the history list to the bottom. */ + /* Put the history pointer back at the bottom of the list. */ if (history_list != NULL) { history_reset(*history_list); free(magichistory);