commit 7bab8780ad9c8ebdf01b9cd9996d38431c1203c4
parent d0dc270eec8ca8eeab9ea5314d340e96bbb67efa
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 23 Aug 2022 10:47:07 +0200
tweaks: rewrap some lines, drop a redundant call, and reshuffle a line
Six years ago, commit a878f5f1 introduced a call of regenerate_screen()
directly in the input routine, which made the call of refresh_func() in
the prompt routine redundant -- except when in the file browser.
Diffstat:
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -1379,9 +1379,8 @@ bool wanted_to_move(void (*func)(void))
/* Return TRUE when the given function makes a change -- no good for view mode. */
bool changes_something(const void *f)
{
- return (f == do_savefile || f == do_writeout || f == do_enter ||
- f == do_tab || f == do_delete || f == do_backspace ||
- f == cut_text || f == paste_text || f == do_replace ||
+ return (f == do_savefile || f == do_writeout || f == do_enter || f == do_tab ||
+ f == do_delete || f == do_backspace || f == cut_text || f == paste_text ||
#ifndef NANO_TINY
f == chop_previous_word || f == chop_next_word ||
f == zap_text || f == cut_till_eof || f == do_execute ||
@@ -1399,7 +1398,7 @@ bool changes_something(const void *f)
#ifdef ENABLE_WORDCOMPLETION
f == complete_a_word ||
#endif
- f == do_verbatim_input);
+ f == do_replace || f == do_verbatim_input);
}
#ifndef NANO_TINY
diff --git a/src/prompt.c b/src/prompt.c
@@ -442,7 +442,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
#ifndef NANO_TINY
/* If the window size changed, go reformat the prompt string. */
if (input == KEY_WINCH) {
- refresh_func();
+ refresh_func(); /* Only needed when in file browser. */
*actual = KEY_WINCH;
#ifdef ENABLE_HISTORIES
free(stored_string);
@@ -595,20 +595,18 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
function = acquire_an_answer(&retval, &listed, history_list, refresh_func);
free(prompt);
- prompt = saved_prompt;
#ifndef NANO_TINY
if (retval == KEY_WINCH)
goto redo_theprompt;
#endif
- /* If we're done with this prompt, restore the x position to what
- * it was at a possible previous prompt. */
+ /* Restore a possible previous prompt and maybe the typing position. */
+ prompt = saved_prompt;
if (function == do_cancel || function == do_enter)
typing_x = was_typing_x;
- /* If we left the prompt via Cancel or Enter, set the return value
- * properly. */
+ /* Set the proper return value for Cancel and Enter. */
if (function == do_cancel)
retval = -1;
else if (function == do_enter)