]> git.mdlowis.com Git - projs/tide.git/commitdiff
clear the redo list when adding a new edit
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 23 Nov 2016 01:47:13 +0000 (20:47 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 23 Nov 2016 01:47:13 +0000 (20:47 -0500)
libedit/buf.c
xedit [new file with mode: 0755]

index 173430207936f8692625a2188dcf18b703fddea6..471deb998073429e4dbcd0879f5e999e73c0a13f 100644 (file)
@@ -139,9 +139,22 @@ static void insert(Buf* buf, unsigned off, Rune rune) {
         *(buf->gapstart++) = rune;
 }
 
+static void clear_redo(Buf* buf) {
+    Log* log = buf->redo;
+    while (log) {
+        Log* deadite = log;
+        log = deadite->next;
+        if (!deadite->insert)
+            free(deadite->data.del.runes);
+        free(deadite);
+    }
+    buf->redo = NULL;
+}
+
 void buf_ins(Buf* buf, unsigned off, Rune rune) {
     buf->modified = true;
     log_insert(&(buf->undo), off, off+1);
+    clear_redo(buf);
     insert(buf, off, rune);
 }
 
@@ -154,6 +167,7 @@ void buf_del(Buf* buf, unsigned off) {
     buf->modified = true;
     Rune r = buf_get(buf, off);
     log_delete(&(buf->undo), off, &r, 1);
+    clear_redo(buf);
     delete(buf, off);
 }
 
diff --git a/xedit b/xedit
new file mode 100755 (executable)
index 0000000..8765c0e
Binary files /dev/null and b/xedit differ