From aaa7aa0632040d1be3b16e4a0680e92035c40e12 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sun, 28 Dec 2025 18:39:21 -0500 Subject: fix txt_byte() not returning 0 at end of buffer it was checking against the length of the buffer, not the piece, so wouldn't work properly after a deletion --- txt.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'txt.c') diff --git a/txt.c b/txt.c index 61b0c22..b3074aa 100644 --- a/txt.c +++ b/txt.c @@ -200,19 +200,14 @@ void txt_free(Txt *t) { u8 txt_byte(Txt *t, TxtLoc l) { TxtPiece *p = &t->ptbl.v[l.p]; TxtBuf *b = &t->buf[p->buf]; - //if (l.p < t->ptbl.n && l.i == p->n) p++, l.i = 0; - if (p->ofs + l.i >= b->n) return 0; + if (l.i >= p->n) return 0; return b->s[p->ofs + l.i]; } u32 txt_chr(Txt *t, TxtLoc l) { TxtPiece *p = &t->ptbl.v[l.p]; TxtBuf *b = &t->buf[p->buf]; - /* - * is this ever executed? - * if (l.p < t->ptbl.n && l.i == p->n) p++, l.i = 0; - */ - return utf8_decode_at(b->s, p->ofs + l.i, b->n); + return utf8_decode_at(b->s, p->ofs + l.i, p->ofs + p->n); } /* cursor manipulation */ -- cgit v1.2.3