]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic to clear modified status if undo state matches the last save
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 13 Sep 2018 01:31:07 +0000 (21:31 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 13 Sep 2018 01:31:07 +0000 (21:31 -0400)
TODO.md
inc/edit.h
lib/buf.c

diff --git a/TODO.md b/TODO.md
index 1e50fe74b4dd597df174822690f1c1102f16746e..437e9782a963c0f36e6bce6c0e61ea2fdb0af584 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -7,7 +7,6 @@ BUGS:
 * no copy indent
 * no magic right click
 * Ctrl+Up,Dn not bound or not working
-* Undo does not clear modified status if state is the same
 * gap buffer does not handle UTF-8 currently
 
 Up Next:
index 5a87aa841569b355f3e97a5146e66ee6e3d91274..60de10fd5f40c3569ffc6366a694a23a9d711798 100644 (file)
@@ -30,6 +30,7 @@ typedef struct {
     char* gapend;     /* end of the gap */
     Log* undo;        /* undo list */
     Log* redo;        /* redo list */
+    Log* save;        /* pointer to last save position */
     int transid;      /* id number of the current transaction */
     Sel selection;    /* the currently selected text */
 } Buf;
index 6244533ea36b15424448c2590e911cbdd9843e1e..4ef2da98a6f73eaaa6f1ee3f731b02bd456f776b 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -100,6 +100,8 @@ int buf_save(Buf* buf, char* path) {
     } else {
         buf->status = ERRORED;
     }
+    if (buf->status == NORMAL)
+        buf->save = buf->undo;
     return buf->status;
 }
 
@@ -243,6 +245,8 @@ static void log_swap(Buf* buf, Log** src, Log** dest) {
         log_swap(buf, src, dest);
     else
         dumplog(buf);
+    if (buf->save == buf->undo)
+        buf->status = NORMAL;
 }
 
 void buf_logstart(Buf* buf) {