commit 3098315e05e343ecf3c5d6f5fa65ff366d0bd1d6
parent 39db2e9d660e5a409dfb1741fe0b4629b217b18a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 28 Feb 2024 11:18:05 +0100
replacing: stash the string to be replaced while asking for replacement
During the Replace-With prompt the user could search in its help text,
which would overwite the 'last_search' string. Make therefore sure that
the latter gets restored to what it was before the Replace-With prompt.
This fixes https://savannah.gnu.org/bugs/?65381.
Bug existed since version 2.8.2,
since searching in a help text became possible.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/search.c b/src/search.c
@@ -707,11 +707,17 @@ void ask_for_and_do_replacements(void)
size_t was_firstcolumn = openfile->firstcolumn;
linestruct *beginline = openfile->current;
size_t begin_x = openfile->current_x;
+ char *replacee = copy_of(last_search);
ssize_t numreplaced;
+
int response = do_prompt(MREPLACEWITH, "", &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
+ /* Set the string to be searched, as it might have changed at the prompt. */
+ free(last_search);
+ last_search = replacee;
+
#ifdef ENABLE_HISTORIES
/* When not "", add the replace string to the replace history list. */
if (response == 0)