files: make the M-F (New Buffer) toggle non-persistent

Having the M-F toggle non-persistent, makes the behavior of ^R
predictable.  This allows string binds that load a file to work
correctly independently of when M-F was last pressed.

The -F/--multibuffer command-line option and "set multibuffer"
in a nanorc file determine the default behavior of ^R.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
This commit is contained in:
Marco Diego Aurélio Mesquita 2020-05-19 15:20:10 -03:00 committed by Benno Schulenberg
parent 26fb83c61f
commit 648eac936e
1 changed files with 10 additions and 0 deletions

View File

@ -1089,6 +1089,9 @@ void do_insertfile(bool execute)
const char *msg; const char *msg;
char *given = copy_of(""); char *given = copy_of("");
/* The last answer the user typed at the status-bar prompt. */ /* The last answer the user typed at the status-bar prompt. */
#ifdef ENABLE_MULTIBUFFER
bool was_multibuffer = ISSET(MULTIBUFFER);
#endif
#ifndef NANO_TINY #ifndef NANO_TINY
format_type was_fmt = openfile->fmt; format_type was_fmt = openfile->fmt;
#endif #endif
@ -1273,6 +1276,13 @@ void do_insertfile(bool execute)
} }
free(given); free(given);
#ifdef ENABLE_MULTIBUFFER
if (was_multibuffer)
SET(MULTIBUFFER);
else
UNSET(MULTIBUFFER);
#endif
} }
/* If the current mode of operation allows it, go insert a file. */ /* If the current mode of operation allows it, go insert a file. */