From 6034f162575519500a9916acd4ea103c5ad34932 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 12 Sep 2018 21:31:07 -0400 Subject: [PATCH] added logic to clear modified status if undo state matches the last save --- TODO.md | 1 - inc/edit.h | 1 + lib/buf.c | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 1e50fe7..437e978 100644 --- 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: diff --git a/inc/edit.h b/inc/edit.h index 5a87aa8..60de10f 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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; diff --git a/lib/buf.c b/lib/buf.c index 6244533..4ef2da9 100644 --- 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) { -- 2.49.0