-
Notifications
You must be signed in to change notification settings - Fork 331
fix: capture visible viewport in VHS.Buffer
#658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: capture visible viewport in VHS.Buffer
#658
Conversation
The `VHS.Buffer` method was incorrectly reading from the top of the scrollback buffer. It now accounts for the scroll position (`viewportY`) to accurately capture the visible terminal viewport
f9bb6d0 to
e9c59ec
Compare
VHS.Buffer to capture visible viewport
VHS.Buffer to capture visible viewportVHS.Buffer
The new name more accurately describes that the method returns only the lines currently visible in the terminal's viewport, improving clarity and consistency with the related `CurrentLine` method.
|
Please @meowgorithm and @andreynering review this pull request so it can be merged & released. If there is anything I can do to speed this up, please let me know. |
|
Awesome work! I ran into the same exact bug recording a demo gif for commit for me. I cloned this repo, applied your patch, and now I have a working demo gif. This does immediately raise a question: What if the output you're Waiting for scrolls past the visible buffer? Anyway, your PR already seems like a huge improvement, so big ups and I hope this can get merged soon! |
That's a good question @codevogel, and as you probably suspect, output may not always be matched if it scrolls past the visible lines. More specifically, I believe the answer is that a
Case in point: Adapting the Will (with the changes in this PR) cause Using Note: The first check passes with the current Adding a brief sleep to allow the Will now match both statements: To summarize, I did consider this potential failure mode when preparing the PR, but opted to keep changes minimal and focused on just fixing the current implementation to work as intended (which I suspect in practice covers the majority of scenarios that call for using It might very well make sense to consider ways to improve the |
Describe your changes
The
VHS.Buffermethod was incorrectly reading from the top of the scrollback buffer.This causes issues when using the
Wait+Screen /regex/command, and when writing output to golden files.The logic now accounts for the scroll position (
viewportY) to capture visible lines in the terminal viewport as expected.More details in the issues linked below (which both include the output after this change in the "Expected Behavior" sections, as well as steps to reproduce the current unexpected behavior).
Additional Style Changes
fill().map()withArray.from()for clarity.CurrentLinesand updated comments for clarity and accuracy.Related issue/discussion
Closes #657, closes #659
Checklist before requesting a review
CONTRIBUTING.md