locking: when finding a lock file at startup, quit when user cancels

When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.
master
Benno Schulenberg 2020-02-02 12:54:34 +01:00
parent 88087f2b2f
commit 7ce1f6d86d
4 changed files with 10 additions and 0 deletions

View File

@ -335,6 +335,10 @@ int do_lockfile(const char *filename, bool ask_the_user)
choice = do_yesno_prompt(FALSE, promptstr);
free(promptstr);
/* When the user cancelled while we're still starting up, quit. */
if (choice < 0 && !we_are_running)
finish();
if (choice < 1) {
retval = -1;
wipe_statusbar();

View File

@ -59,6 +59,9 @@ bool started_curses = FALSE;
bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for current keystroke? */
bool we_are_running = FALSE;
/* Will become TRUE as soon as all options and files have been read. */
message_type lastmessage = HUSH;
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */

View File

@ -2573,6 +2573,8 @@ int main(int argc, char **argv)
statusbar(_("Welcome to nano. For basic help, type Ctrl+G."));
#endif
we_are_running = TRUE;
while (TRUE) {
#ifdef ENABLE_LINENUMBERS
confirm_margin();

View File

@ -43,6 +43,7 @@ extern bool control_C_was_pressed;
extern bool suppress_cursorpos;
extern bool started_curses;
extern bool we_are_running;
extern message_type lastmessage;