commit 821fbf713d5a1e815f8e3ad3783b11ae9057d7ba
parent ebc23647426b0796651132e12b68e543b9b4270c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 14 May 2020 11:41:49 +0200
tweaks: reshuffle a bit of code, to elide an #ifndef
Diffstat:
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -68,7 +68,7 @@ void do_deletion(undo_type action)
/* If there is a magic line, and we're before it: don't eat it. */
if (joining == openfile->filebot && openfile->current_x != 0 &&
- !ISSET(NO_NEWLINES)) {
+ !ISSET(NO_NEWLINES)) {
#ifndef NANO_TINY
if (action == BACK)
add_undo(BACK, NULL);
@@ -78,14 +78,8 @@ void do_deletion(undo_type action)
#ifndef NANO_TINY
add_undo(action, NULL);
-#endif
- /* Add the contents of the next line to those of the current one. */
- openfile->current->data = charealloc(openfile->current->data,
- strlen(openfile->current->data) + strlen(joining->data) + 1);
- strcat(openfile->current->data, joining->data);
-#ifndef NANO_TINY
- /* Adjust the mark if it was on the line that was "eaten". */
+ /* Adjust the mark if it is on the line that will be "eaten". */
if (openfile->mark == joining) {
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
@@ -93,10 +87,15 @@ void do_deletion(undo_type action)
openfile->current->has_anchor |= joining->has_anchor;
#endif
+ /* Add the content of the next line to that of the current one. */
+ openfile->current->data = charealloc(openfile->current->data,
+ strlen(openfile->current->data) + strlen(joining->data) + 1);
+ strcat(openfile->current->data, joining->data);
+
unlink_node(joining);
- renumber_from(openfile->current);
- /* Two lines were joined, so we need to refresh the screen. */
+ /* Two lines were joined, so do a renumbering and refresh the screen. */
+ renumber_from(openfile->current);
refresh_needed = TRUE;
} else
/* We're at the end-of-file: nothing to do. */