diff options
| author | WormHeamer | 2026-01-03 06:01:46 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-03 06:01:46 -0500 |
| commit | db8eea8baf396a965cc0c07ea8649dead043747f (patch) | |
| tree | 6aea84547864dad87bb1ea3f5f3c05ae3664ba4a | |
| parent | f34794f3e298bd5014ad6329d5bc8f015db042aa (diff) | |
hopefully squash the history corruption bug once and for all
| -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) { |
