search: avoid a crash after a nested search, reported by correctmost

When going back to a previous prompt, restore the typing position
also for 'to_first_line' (^Y) and 'to_last_line (^V).

This fixes https://savannah.gnu.org/bugs/?65278.

Bug existed since version 5.9, commit 6d5b1656, which allowed exiting
from a Search-in-help prompt with ^Y or ^V.
This commit is contained in:
Benno Schulenberg 2024-02-11 12:05:56 +01:00
parent 8fefee2d41
commit 206b4e2a7e

View File

@ -603,7 +603,8 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
/* Restore a possible previous prompt and maybe the typing position. */
prompt = saved_prompt;
if (function == do_cancel || function == do_enter)
if (function == do_cancel || function == do_enter ||
function == to_first_line || function == to_last_line)
typing_x = was_typing_x;
/* Set the proper return value for Cancel and Enter. */