-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Terminal layout issue (column count seems off by one ?) #411
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
Comments
I believe this is an issue with tab stops. It seems that the wsl shell starts up with no tab stops set by default, so when you output a tab, the cursor jumps right to the end of the line. You can reproduce this with a simple Interestingly the cmd.exe shell doesn't appear to have this problem - it's initialized with tab stops every 8 columns as you'd expect. And if you start a bash shell from the cmd shell then that will have the tab stops set correctly too. |
I want to say this is fixed in the latest release, but I can't get the original case to repro. @AloyseTech can you see if updating Windows fixes this? |
I still have the issue on Windows 10 17763.557. Do I need to update WSL alone somehow? |
@AloyseTech Oh, I mean you need to update Windows 10 to 18362 |
I've just updated to 10.0.18362 (don't know why I was still on the other version), but the problem is still here... |
Good to know! I'll move it to the right milestone and investigate soontm |
Honestly I have no idea. Does this repro in other shells? If it doesn't, we can narrow it down to |
I can still reproduce this with a recent local build (commit 537258a). The trick is to have the With |
OK, I think I know what's going on. By default the terminal/src/host/screenInfo.cpp Lines 72 to 75 in 537258a
Later on Lines 409 to 414 in 12d2e17
Bottom line, if the |
Woah. Well that's messed up. Seems like the easy fix is if we're constructing the buffer with |
* fixes #411 * update this comment to actually match * run this test in isolation so it doesn't break other tests, @DHowett-MSFT * This fixes the test that's broken? Kinda raises more questions tbh
* fixes #411 * update this comment to actually match * run this test in isolation so it doesn't break other tests, @DHowett-MSFT * This fixes the test that's broken? Kinda raises more questions tbh (cherry picked from commit dfaaa44)
🎉This issue was addressed in #2816, which has now been successfully released as Handy links: |
@zadjii-msft I still have the issue after updating everything I could update. I installed the Terminal Preview as well. Maybe I misunderstanding something, but when I launch WSL terminal via the Ubuntu icon, the terminal TAB is still messed up... |
@AloyseTech What Windows version are you using? This was fixed for the Terminal in 0.5, but I'm not sure the Windows release that will fix the legacy/inbox console has actually been released yet. |
@zadjii-msft I'm running Windows 10 1909 18363.592 |
... I'm realizing now I have now idea how our version numbers work for the last two releases. @DHowett-MSFT I think #2816 landed in Vb, would that be 18363.592 publicly, or is it not out yet? |
Alas! 18363 is "19H2", a targeted set of backports to 19H1. 😄 |
So the fix is not yet ready, right? |
@AloyseTech Nope, looks like it's not. I'm not sure what the next major Windows release build number will be, but that should have the fix. |
## 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 * [x] Closes #4669 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] 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.
Your Windows build number: (Type
ver
at a Windows Command Prompt)Microsoft Windows [version 10.0.17763.437]
What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)

using git command line in the terminal in a zsh shell
git command output layout is messed up (seems like the number of column of the terminal is off by one)
What's wrong / what should be happening instead:
Wen I open a Ubuntu terminal with WSL, the git commend output layout is messed up. I have to use
reset
and it fixes the layout in the following commands.The text was updated successfully, but these errors were encountered: