Skip to content
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

Reimplement the VT tab stop functionality #5173

Merged
7 commits merged into from
Apr 1, 2020

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Mar 29, 2020

Summary of the Pull Request

This is essentially a rewrite of the VT tab stop functionality, implemented entirely within the AdaptDispatch class. This significantly simplifies the ConGetSet interface, and should hopefully make it easier to share the functionality with the Windows Terminal VT implementation in the future.

By removing the dependence on the SCREEN_INFORMATION class, it fixes the problem of the the tab state not being preserved when switching between the main and alternate buffers. And the new architecture also fixes problems with the tabs not being correctly initialized when the screen is resized.

References

This fixes one aspect of issue #3545.
It also supersedes the fix for #411 (PR #2816).
I'm hoping the simplification of ConGetSet will help with #3849.

PR Checklist

  • Closes Issue with line-wrapped tabstops after resizing the window #4669
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

In the new tab architecture, there is now a vector<bool> (_tabStopColumns), which tracks whether any particular column is a tab stop or not. There is also a _initDefaultTabStops flag indicating whether the default tab stop positions need to be initialised when the screen is resized.

The way this works, the vector is initially empty, and only initialized (to the current width of the screen) when it needs to be used. When the vector grows in size, the _initDefaultTabStops flag determines whether the new columns are set to false, or if every 8th column is set to true.

By default we want the latter behaviour - newly revealed columns should have default tab stops assigned to them - so _initDefaultTabStops is set to true. However, after a TBC 3 operation (i.e. we've cleared all tab stops), there should be no tab stops in any newly revealed columns, so _initDefaultTabStops is set to false.

Note that the _tabStopColumns vector is never made smaller when the window is shrunk, and that way it can preserve the state of tab stops that are off screen, but which may come into range if the window is made bigger again.

However, we can can still reset the vector completely after an RIS or TBC 3 operation, since the state can then be reconstructed automatically based on just the _initDefaultTabStops flag.

Validation Steps Performed

The original screen buffer tests had to be rewritten to set and query the tab stop state using escape sequences rather than interacting with the SCREEN_INFORMATION class directly, but otherwise the structure of most tests remained largely the same.

However, the alt buffer test was significantly rewritten, since the original behaviour was incorrect, and the initialization test was dropped completely, since it was no longer applicable. The adapter tests were also dropped, since they were testing the ConGetSet interface which has now been removed.

I also had to make an addition to the method setup of the screen buffer tests (making sure the viewport was appropriately initialized), since there were some tests (unrelated to tab stops) that were previously dependent on the state being set in the tab initialization test which has now been removed.

I've manually tested the issue described in #4669 and confirmed that the tabs now produce the correct spacing after a resize.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class act as always. Thank you, @j4james

src/terminal/adapter/adaptDispatch.cpp Show resolved Hide resolved
src/terminal/adapter/adaptDispatch.cpp Show resolved Hide resolved
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So wait, just to be clear, the main and alt buffer are supposed to share one set of tab stops?

src/terminal/adapter/adaptDispatch.cpp Show resolved Hide resolved
src/terminal/adapter/adaptDispatch.cpp Outdated Show resolved Hide resolved
@j4james
Copy link
Collaborator Author

j4james commented Mar 31, 2020

So wait, just to be clear, the main and alt buffer are supposed to share one set of tab stops?

Yep. There's a test case in #3545 which demonstrates this issue and a screenshot of the XTerm behaviour. VTE and Mintty work the same way.

@j4james
Copy link
Collaborator Author

j4james commented Mar 31, 2020

Note that build failure is just a timeout in the unit tests. The second last commit was fine, and the one that followed was just a comment fix, so no reason it should make any difference.

@DHowett-MSFT
Copy link
Contributor

Kicked the failed test.

@DHowett-MSFT
Copy link
Contributor

The two Mikes, who would otherwise be reviewing and/or signing off, aren't available today -- this might take a little bit to get merged, but I'll tag it for Auto and Second.

@DHowett-MSFT DHowett-MSFT added AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off labels Mar 31, 2020
@ghost ghost requested review from miniksa, carlos-zamora and leonMSFT March 31, 2020 20:49
@ghost
Copy link

ghost commented Mar 31, 2020

Hello @DHowett-MSFT!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@DHowett-MSFT
Copy link
Contributor

@msftbot make sure @zadjii-msft signs off

@ghost
Copy link

ghost commented Mar 31, 2020

Hello @DHowett-MSFT!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @zadjii-msft

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@j4james
Copy link
Collaborator Author

j4james commented Mar 31, 2020

The two Mikes, who would otherwise be reviewing and/or signing off, aren't available today -- this might take a little bit to get merged, but I'll tag it for Auto and Second.

That's cool. I wasn't expecting you'd even look at it before the v1 release. I'm not in any rush to get anything merged.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying!

@ghost ghost merged commit 9a0b6e3 into microsoft:master Apr 1, 2020
@j4james j4james deleted the refactor-vt-tabstops branch April 2, 2020 13:32
@ghost
Copy link

ghost commented Apr 22, 2020

🎉Windows Terminal Preview v0.11.1121.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with line-wrapped tabstops after resizing the window
3 participants