diff options
Diffstat (limited to 'txt.c')
| -rw-r--r-- | txt.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -278,20 +278,22 @@ void txt_hist_push(Txt *t, TxtLoc cur) { return; } if (t->hist.i + 1 < t->hist.n) t->hist.n = t->hist.i + 1; - if (t->hist.n == TXT_HIST_MAX) { - /* TODO: this is maybe still buggy? */ + if (t->hist.n) t->hist.i++; + if (t->hist.i == TXT_HIST_MAX) { free(t->hist.v[0].v); MOVE(&t->hist.v[0], &t->hist.v[1], TXT_HIST_MAX - 1); + MOVE(&t->hist.cur[0], &t->hist.cur[1], TXT_HIST_MAX - 1); + memset(&t->hist.v[TXT_HIST_MAX - 1], 0, sizeof(*t->hist.v)); t->hist.i--; t->hist.n--; } - if (t->hist.i + 1 == t->hist.n) t->hist.i++; DA_FIT(&t->hist.v[t->hist.i], t->ptbl.n); memcpy(t->hist.v[t->hist.i].v, t->ptbl.v, sizeof(TxtPiece) * t->ptbl.n); t->hist.v[t->hist.i].n = t->ptbl.n; t->hist.v[t->hist.i].dirty = t->ptbl.dirty; t->hist.cur[t->hist.i] = cur; t->hist.n++; + ASSERT(t->hist.n == t->hist.i + 1); } int txt_hist_set(Txt *t, TxtLoc *cur) { |
