Fix interpretation of DECSTBM margin parameters #1881
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
When setting the scroll margins with the DECSTBM escape sequence, some of the edge cases are interpreted incorrectly. If the top margin is equal to the bottom margin, or the bottom margin is greater than the screen height, the command should be ignored, but at the moment it isn't. This PR fixes those cases.
Tested manually and with additional adapter unit tests.
PR Checklist
Detailed Description of the Pull Request / Additional comments
This is a slight rewrite of the
AdaptDispatch::_DoSetTopBottomScrollingMarginsmethod which I think should be a little easier to follow.Validation Steps Performed
I've added a few more unit tests to the
ScrollMarginsTestin adapterTest.cpp to validate the specific edge cases that were previously incorrect: the top margin being equal to the bottom margin, the top margin being out of range, and the bottom margin being out of range. There was also a weird range of 1,0 which should have cleared the margins but didn't.While adding these tests, I noticed a couple of the existing tests weren't correct. They were meant to be testing whether certain full screen ranges would clear the margins, but the expected values weren't correctly set, and the tested ranges weren't covering the full screen. So while the tests passed, they weren't actually testing what they claimed to be. This PR also includes fixes for those tests.