]> git.wh0rd.org Git - nano.git/commitdiff
Making splice_node() update 'filebot', instead of doing it in
authorBenno Schulenberg <bensberg@justemail.net>
Tue, 8 Dec 2015 15:29:56 +0000 (15:29 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Tue, 8 Dec 2015 15:29:56 +0000 (15:29 +0000)
four different places.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5490 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/nano.c
src/text.c

index 861963d30ed57a98caaa4b84b88521d33b303cba..c71c7fde7c3bb130efe05ec603a1cae64bced0ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-12-08  Benno Schulenberg  <bensberg@justemail.net>
+       * src/nano.c (splice_node): Make this function update 'filebot',
+       instead of doing it in four different places.
+
 2015-12-07  Benno Schulenberg  <bensberg@justemail.net>
        * src/winio.c (edit_draw): Quit the loop when there is no end match.
        * src/files.c (do_writeout): When --tempfile is given, make ^O not
index b795fe9f2886f9841fc29f49617fdc610e0ba72b..310616ed0a61575619e268c9a250b07057f03437 100644 (file)
@@ -104,6 +104,10 @@ void splice_node(filestruct *afterthis, filestruct *newnode)
     if (afterthis->next != NULL)
        afterthis->next->prev = newnode;
     afterthis->next = newnode;
+
+    /* Update filebot when inserting a node at the end of file. */
+    if (openfile && openfile->filebot == afterthis)
+       openfile->filebot = newnode;
 }
 
 /* Unlink a node from the rest of the filestruct and delete it. */
index 622717268d6edc22c4e19d836283100f0f6f22bf..d1871da4c66d07cc3185baf91e9eac5a31713658 100644 (file)
@@ -544,8 +544,6 @@ void do_undo(void)
        free(f->data);
        f->data = data;
        splice_node(f, t);
-       if (f == openfile->filebot)
-           openfile->filebot = t;
        goto_line_posx(u->lineno, u->begin);
        break;
     case CUT_EOF:
@@ -678,8 +676,6 @@ void do_redo(void)
        free(f->data);
        f->data = data;
        splice_node(f, shoveline);
-       if (f == openfile->filebot)
-           openfile->filebot = shoveline;
        renumber(shoveline);
        goto_line_posx(u->lineno + 1, u->mark_begin_x);
        break;
@@ -798,9 +794,6 @@ void do_enter()
     openfile->current_x = extra;
 
     splice_node(openfile->current, newnode);
-
-    if (openfile->current == openfile->filebot)
-       openfile->filebot = newnode;
     openfile->current = newnode;
     renumber(newnode);
 
@@ -2162,9 +2155,7 @@ void do_justify(bool full_justify)
 
            assert(break_pos <= line_len);
 
-           /* Make a new line, and copy the text after where we're
-            * going to break this line to the beginning of the new
-            * line. */
+           /* Insert a new line after the current one. */
            splice_node(openfile->current, make_new_node(openfile->current));
 
            /* If this paragraph is non-quoted, and autoindent isn't
@@ -2203,11 +2194,6 @@ void do_justify(bool full_justify)
            /* Break the current line. */
            null_at(&openfile->current->data, break_pos);
 
-           /* If the current line is the last line of the file, move
-            * the last line of the file down to the next line. */
-           if (openfile->filebot == openfile->current)
-               openfile->filebot = openfile->filebot->next;
-
            /* Go to the next line. */
            par_len--;
            openfile->current_y++;