From aba4f4e0e2a7956b7313ec971bb00248e10bb550 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 21 Aug 2022 09:55:22 +0200 Subject: [PATCH] tweaks: avoid sometimes calling a function three times in a row --- src/prompt.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/prompt.c b/src/prompt.c index b105bd12..28622d36 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -639,6 +639,7 @@ int ask_user(bool withall, const char *question) const char *yesstr = _("Yy"); const char *nostr = _("Nn"); const char *allstr = _("Aa"); + functionptrtype function; while (choice == UNDECIDED) { #ifdef ENABLE_NLS @@ -730,12 +731,18 @@ int ask_user(bool withall, const char *question) choice = NO; else if (withall && strchr("Aa", kbinput) != NULL) choice = ALL; - else if (func_from_key(kbinput) == do_cancel) + + if (choice != UNDECIDED) + break; + + function = func_from_key(kbinput); + + if (function == do_cancel) choice = CANCEL; - else if (func_from_key(kbinput) == full_refresh) + else if (function == full_refresh) full_refresh(); #ifndef NANO_TINY - else if (func_from_key(kbinput) == do_toggle) { + else if (function == do_toggle) { TOGGLE(NO_HELP); window_init(); titlebar(NULL);