]> git.wh0rd.org Git - nano.git/commitdiff
- Add redo of an insert
authorChris Allegretta <chrisa@asty.org>
Sun, 3 Aug 2008 20:19:42 +0000 (20:19 +0000)
committerChris Allegretta <chrisa@asty.org>
Sun, 3 Aug 2008 20:19:42 +0000 (20:19 +0000)
- Fix bug in fsfromlineno
- Tiny cleanups in undo

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

src/text.c
src/utils.c

index 0564cb9c34c3730f60f63ed7fb401f36b7ed3459..5226a321250afee3f4897f3f463c9090005fbfd9 100644 (file)
@@ -498,6 +498,7 @@ void do_redo(void)
 {
     undo *u = openfile->undotop;
     filestruct *f = openfile->current, *t;
+    filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
     int len = 0, i;
     char *undidmsg, *data;
 
@@ -619,6 +620,15 @@ void do_redo(void)
        u->strdata = f->data;
        f->data = data;
        break;
+     case INSERT:
+       undidmsg = _("text insert");
+       cutbuffer = u->cutbuffer;
+       cutbottom = u->cutbottom;
+       do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
+       do_uncut_text();
+       cutbuffer = oldcutbuffer;
+       cutbottom = oldcutbottom;
+       break;
     default:
        undidmsg = _("wtf?");
        break;
@@ -804,11 +814,8 @@ void add_undo(undo_type current_action)
        fs->undotop = fs->undotop->next;
        if (u2->strdata != NULL)
            free(u2->strdata);
-       while (u2->cutbuffer != NULL) {
-           filestruct *f2 = u2->cutbuffer->next;
-           u2->cutbuffer = u2->cutbuffer->next;
-           free(f2);
-       }
+       if (u2->cutbuffer);
+           free_filestruct(u2->cutbuffer);
        free(u2);
     }
 
index d09118fa2490c990c58ad0b65e7c72abf9735fea..0c10f46bf4516f37cd82e97c754d8dd9d8cd2d8d 100644 (file)
@@ -613,10 +613,10 @@ filestruct *fsfromline(ssize_t lineno)
           ;
     else
         for (; f->lineno != lineno && f->next != NULL; f = f->next)
+           ;
 
     if (f->lineno != lineno)
-       return NULL;
-
+       f = NULL;
     return f;
 }