From 5712fe4731ec14302ca206b807cc5bc9fddd7576 Mon Sep 17 00:00:00 2001 From: Augustinas Malinauskas Date: Mon, 16 Feb 2026 07:23:12 +0800 Subject: [PATCH] fix: use viewportY offset in Buffer() to read visible viewport Buffer() was reading lines from the top of the scrollback buffer (index 0..N) instead of the visible viewport. This caused Wait+Screen to fail after the terminal scrolled, since it matched against lines no longer visible on screen. The fix adds viewportY as the starting offset, consistent with how CurrentLine() already works in the same file. Fixes #659 --- testing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing.go b/testing.go index f3b8ac0c..723dd6c0 100644 --- a/testing.go +++ b/testing.go @@ -67,7 +67,7 @@ func (v *VHS) SaveOutput() error { // Buffer returns the current buffer. func (v *VHS) Buffer() ([]string, error) { // Get the current buffer. - buf, err := v.Page.Eval("() => Array(term.rows).fill(0).map((e, i) => term.buffer.active.getLine(i).translateToString().trimEnd())") + buf, err := v.Page.Eval("() => { const s = term.buffer.active.viewportY; return Array(term.rows).fill(0).map((e, i) => term.buffer.active.getLine(s + i).translateToString().trimEnd()); }") if err != nil { return nil, fmt.Errorf("read buffer: %w", err) }