diff options
author | 2013-03-25 11:38:22 +0000 | |
---|---|---|
committer | 2013-03-25 11:38:22 +0000 | |
commit | b5c940e65652c4c0d20d33e248f3784c0cbb2c93 (patch) | |
tree | 61c5b16a60482ca0736f202dd4c9e70c3c5cbca6 | |
parent | Clean up capture-pane and add -P option to dump pending output, based on (diff) | |
download | wireguard-openbsd-b5c940e65652c4c0d20d33e248f3784c0cbb2c93.tar.xz wireguard-openbsd-b5c940e65652c4c0d20d33e248f3784c0cbb2c93.zip |
Record when the buffer was saved in the undo history. The buffer
will be marked unchanged at the correct point when stepping
through the undo history.
OK jasper@
-rw-r--r-- | usr.bin/mg/file.c | 6 | ||||
-rw-r--r-- | usr.bin/mg/undo.c | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index c46e888ad50..e4d5660063b 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.86 2013/02/10 15:38:18 lum Exp $ */ +/* $OpenBSD: file.c,v 1.87 2013/03/25 11:38:22 florian Exp $ */ /* This file is in the public domain. */ @@ -553,6 +553,8 @@ filewrite(int f, int n) (void)fupdstat(curbp); curbp->b_flag &= ~(BFBAK | BFCHG); upmodes(curbp); + undo_add_boundary(FFRAND, 1); + undo_add_modified(); } return (s); } @@ -623,6 +625,8 @@ buffsave(struct buffer *bp) (void)fupdstat(bp); bp->b_flag &= ~(BFCHG | BFBAK); upmodes(bp); + undo_add_boundary(FFRAND, 1); + undo_add_modified(); } return (s); } diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c index ba524e8f357..ab10a452272 100644 --- a/usr.bin/mg/undo.c +++ b/usr.bin/mg/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.51 2012/11/06 18:04:10 florian Exp $ */ +/* $OpenBSD: undo.c,v 1.52 2013/03/25 11:38:22 florian Exp $ */ /* * This file is in the public domain */ @@ -239,7 +239,13 @@ undo_add_boundary(int f, int n) void undo_add_modified(void) { - struct undo_rec *rec; + struct undo_rec *rec, *trec; + + TAILQ_FOREACH_SAFE(rec, &curbp->b_undo, next, trec) + if (rec->type == MODIFIED) { + TAILQ_REMOVE(&curbp->b_undo, rec, next); + free_undo_record(rec); + } rec = new_undo_record(); rec->type = MODIFIED; |