nano

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

commit 38af812a82fc0d684c1629c82e8a900762f8887c
parent 622111613f9f93a2cc44d66ea45f8b055e72235b
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  6 Mar 2020 16:57:22 +0100

tweaks: reshuffle the setting of the starting point of a cut

Diffstat:
Msrc/files.c | 15+++++----------
Msrc/text.c | 5+++++
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -484,25 +484,20 @@ bool replace_buffer(const char *filename, undo_type action, bool marked, if (descriptor < 0) return FALSE; + cutbuffer = NULL; + #ifndef NANO_TINY add_undo(COUPLE_BEGIN, operation); -#endif - - /* When nothing is marked, start at the top of the buffer. */ - if (!marked) { - openfile->current = openfile->filetop; - openfile->current_x = 0; - } - /* Throw away the marked region or the whole buffer. */ - cutbuffer = NULL; -#ifndef NANO_TINY + /* Cut either the marked region or the whole buffer. */ add_undo(action, NULL); #endif do_snip(FALSE, marked, !marked, FALSE); #ifndef NANO_TINY update_undo(action); #endif + + /* Discard what was cut. */ free_lines(cutbuffer); cutbuffer = was_cutbuffer; diff --git a/src/text.c b/src/text.c @@ -2561,9 +2561,14 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling) openfile->mark = line_from_number(was_mark_lineno); } else #endif + { + openfile->current = openfile->filetop; + openfile->current_x = 0; + replaced = replace_buffer(tempfile_name, CUT_TO_EOF, FALSE, /* TRANSLATORS: The next two go with Undid/Redid messages. */ (spelling ? N_("spelling correction") : N_("formatting"))); + } /* Go back to the old position. */ goto_line_posx(lineno_save, current_x_save);