From cf63a2910a86295d42e6003cd51ad5e558c5f2d2 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 22 Nov 2017 20:56:37 +0100 Subject: [PATCH] files: save the marked region only when we've prompted for a file name Otherwise we would overwrite the current file with just the selection. This fixes https://savannah.gnu.org/bugs/?52482. --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index 229438fa..382ccb19 100644 --- a/src/files.c +++ b/src/files.c @@ -2242,7 +2242,7 @@ int do_writeout(bool exiting, bool withprompt) * function is disabled, since it allows reading from or * writing to files not specified on the command line. */ #ifndef NANO_TINY - if (openfile->mark && !exiting && !ISSET(RESTRICTED)) + if (openfile->mark && !exiting && withprompt && !ISSET(RESTRICTED)) result = write_marked_file(answer, NULL, FALSE, method); else #endif