nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0f23729253d6ded924f2d2be2843282dae02e0d8
parent 3def429290f5920bcc4ce64f221bf210134e5c97
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 27 Mar 2022 18:20:17 +0200

tweaks: prevent the adding of an unwanted newline in a different way

The prevention is needed only for temporary files, not for normal files.

Diffstat:
Msrc/files.c | 2+-
Msrc/text.c | 3---
2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -2085,7 +2085,7 @@ bool write_region_to_file(const char *name, FILE *stream, bool normal, get_region(&topline, &top_x, &botline, &bot_x); /* When needed, prepare a magic end line for the region. */ - if (bot_x > 0 && !ISSET(NO_NEWLINES)) { + if (normal && bot_x > 0 && !ISSET(NO_NEWLINES)) { stopper = make_new_node(botline); stopper->data = copy_of(""); } else diff --git a/src/text.c b/src/text.c @@ -2516,9 +2516,6 @@ void do_spell(void) /* Save the settings of the global flags. */ memcpy(stash, flags, sizeof(flags)); - /* Don't add an extra newline when writing out the (selected) text. */ - SET(NO_NEWLINES); - #ifndef NANO_TINY if (openfile->mark) okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);