Fix continued line detection once scrollback has wrapped around

This commit is contained in:
rudolf-blue 2026-10-08 14:46:56 -04:00
parent 1adf1fbb76
commit 68bc11d2ce
2 changed files with 10 additions and 2 deletions

View file

@ -186,7 +186,7 @@ index_of(HistoryBuf *self, index_type lnum) {
static bool
hb_line_is_continued(HistoryBuf *self, index_type num) {
if (num == 0) {
if (num == self->start_of_data) {
size_t sz;
if (self->pagerhist && self->pagerhist->ringbuf && (sz = ringbuf_bytes_used(self->pagerhist->ringbuf)) > 0) {
size_t pos = ringbuf_findchr(self->pagerhist->ringbuf, '\n', sz - 1);
@ -194,7 +194,7 @@ hb_line_is_continued(HistoryBuf *self, index_type num) {
}
return false;
}
return cpu_lineptr(self, num - 1)[self->xnum - 1].next_char_was_wrapped;
return cpu_lineptr(self, (num + self->ynum - 1) % self->ynum)[self->xnum - 1].next_char_was_wrapped;
}
static void

View file

@ -820,6 +820,14 @@ class TestDataTypes(BaseTest):
self.assertEqual(p.wait(timeout=30), 0)
p.stdout.close()
def test_historybuf_continued_after_wraparound(self):
s = self.create_screen(cols=5, lines=2, scrollback=4)
for i in range(7):
s.draw(str(i) * 7)
s.carriage_return(), s.linefeed()
hb = s.historybuf
self.ae([hb.is_continued(y) for y in range(hb.count)], [True, False, True, False])
def test_historybuf(self):
lb = filled_line_buf()
hb = HistoryBuf(5, 5)