From: Michael D. Lowis Date: Wed, 23 Nov 2016 01:47:13 +0000 (-0500) Subject: clear the redo list when adding a new edit X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=2d70d7c2ac2a5f0aa39be00bcd1ebbeb65258c37;p=projs%2Ftide.git clear the redo list when adding a new edit --- diff --git a/libedit/buf.c b/libedit/buf.c index 1734302..471deb9 100644 --- a/libedit/buf.c +++ b/libedit/buf.c @@ -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 index 0000000..8765c0e Binary files /dev/null and b/xedit differ