Skip to content

Testing output doesn't capture the viewport when the terminal content scrollsΒ #657

@runesoerensen

Description

@runesoerensen

Describe the bug

When a .tape file generates enough output to cause the terminal to scroll, the testing/golden file outputs (.txt, .ascii, .test) fail to capture the current viewport. Instead of saving the visible lines, vhs repeatedly writes the lines from the top of the buffer.

This issue likely stems from the VHS.Buffer method, which appears to not account for the scroll position when generating the output frame.

Setup

  • OS: macOS (15.6.1)
  • Shell: zsh, bash, nu

To Reproduce

  1. Create a file named testing-output.tape with the following content.

    Set Height 300
    Output testing-output.ascii
    
    Type "echo $LINES"
    Enter
    
    Type "seq 10"
    Enter
    
    Type "echo foo"
    Enter
    
  2. Run the tape file: vhs testing-output.tape.

  3. Inspect the generated testing-output.ascii file.

Actual Behavior

The output file captures the top of the buffer at each step. The final frames are missing the scrolled output from seq 10 and the subsequent echo foo command.

────────────────────────────────────────────────────────────────────────────────
> echo $LINES





────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
>



────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
> seq 10



────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
> seq 10
1
2
3
────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
> seq 10
1
2
3
────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
> seq 10
1
2
3
────────────────────────────────────────────────────────────────────────────────

Expected Behavior

The output file should accurately reflect the terminal's viewport at each step, showing the content as it scrolls into view, e.g., like this:

────────────────────────────────────────────────────────────────────────────────
> echo $LINES





────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
>



────────────────────────────────────────────────────────────────────────────────
> echo $LINES
6
> seq 10



────────────────────────────────────────────────────────────────────────────────
6
7
8
9
10
>
────────────────────────────────────────────────────────────────────────────────
6
7
8
9
10
> echo foo
────────────────────────────────────────────────────────────────────────────────
8
9
10
> echo foo
foo
>
────────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions