diff options
| author | WormHeamer | 2025-12-28 18:39:21 -0500 |
|---|---|---|
| committer | WormHeamer | 2025-12-28 18:39:21 -0500 |
| commit | aaa7aa0632040d1be3b16e4a0680e92035c40e12 (patch) | |
| tree | c81e93af890afb7e621146bd4e50221aef066ae9 /txt.c | |
| parent | d473a991d015130c59690f2e8738121216e20860 (diff) | |
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
Diffstat (limited to 'txt.c')
| -rw-r--r-- | txt.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -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 */ |
