-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
TAB character shouldn't move past the end of the line #3168
Comments
Let's also note (and verify) that
So with this command:
assuming the window is not too wide, tons of tab both before and after B should be ignored. B should be at the end of the line, C at the begining of the next line (under A). |
I know that's what XTerm does, but I'm not sure that's correct. If instead you had this:
The result would be the And if you look at page D-13 of the DEC STD 070 manual, this is what it says:
And then goes on to list a bunch of controls, including HORIZONTAL TAB. Then again it also says that "existing products vary widely in their handling of the end-of-line condition in regards to resetting the Last Column Flag", so I don't suppose it matters that much. If we really think that the XTerm behaviour is preferable, though, that's going to be a more complicated change, so I think it's best addressed as a separate issue.
Vttest actually. I don't really think there's a lot of practical value in passing half of those tests, but that's how many people will judge the quality of our terminal emulation, so I'd like to try and get some of those outstanding issues fixed. |
Indeed, this seems to say a TAB should move "back" in some sense (clear pending wrap). (Note: I'm not checking the spec, only the bits you quoted.)
I'd argue that it's not essentially the same. It could be if TAB was strictly considered a cursor positioning control escape sequence. Instead, TAB is commonly used in plain text files of all kinds, where "real" escapes equences (e.g. ones beginning with the ESC char, as well as other controls like SI SO) don't occur. TAB is frequently placed in text files even in environments that have nothing to do with terminal emulation (e.g. graphical text editors). We migh argue whether it's good or not, and whether it was intended so in the early days, but anyway, that's how it ended up. It is already bad that simply printing such a file to the terminal doesn't preserve the entire amount of requested indentation (including when the terminal is subsequently resized to be wide enough). It is even worse that near the margin it might completely drop TABs, i.e. two words that are supposed to be separated become logically joined across a linewrap (unless you implement some real magic remembering this state and somehow taking into account for rewrap, word double click selection etc. – a new state that differs both from an explicit newline and from a long word simply wrapping). But dropping a character from the output would IMO be unacceptable. IMO it's a case where common sense needs to override the spec :)
Fair enough. (Note: Don't blindly aim for 100% pass rate. E.g. bullet point 2, screen 2 "Test of TAB setting/resetting" used to pass in VTE but fails nowadays after a change in VTE. Examining the situation reveals that VTE implements the standards correctly, vttest is faulty here.) |
I don't want to sound like I'm defending vttest, because I think that particular test is silly, but I wouldn't necessarily call it faulty. It's just that you're implementing a part of the ANSI standard which I don't think the VT terminals ever supported (at least as far I know), so for a VT test there is some justification in expecting that parameter to be ignored. Also, I personally don't see the point in implementing only one bit of the spec without the rest of the line tabulation support (unless you know of some app that depends on just that one sequence). So for now at least, I would definitely expect us to be passing that vttest in its current form. |
Could be. I can't recall of the top of my head what this issue was exactly about, and I'm lazy to look it up now if you don't mind :)
Fair enough. I am by no means suggesting that you should fail it because it's buggy :-) I think it's perfectly fine if you pass it, and a great improvement from the current state. Just keep in mind that vttest isn't necessarily fully authoritative or correct. Maybe you'll find another case that you do right in WT whereas vttest is faulty, who knows. |
🎉This issue was addressed in #3197, which has now been successfully released as Handy links: |
Environment
Windows build number: Version 10.0.18362.295
Also tested in a recent conhost build: commit 82dd0b9
Steps to reproduce
Open a bash shell and execute:
This outputs an
A
, then aCUF
sequence to move the cursor position to the end of the line, then aTAB
control character, and finally aB
.Expected behavior
When in VT mode, a
TAB
character should not move the cursor position past the end of the line, so theB
should be output on the same line as theA
, in the last column.Here's what the above test case looks like in XTerm:
Actual behavior
The
TAB
moves the cursor position onto the start of the next line, so theB
is output below theA
.This is what the test case looks like in the Windows console:
Proposed fix
In the
SCREEN_INFORMATION::GetForwardTab
method, simply get rid of the first condition that checks for the cursor being in the last column. See here:terminal/src/host/screenInfo.cpp
Lines 2222 to 2230 in 82dd0b9
That case should be handled by the second condition (any X pos greater than or equal to the last tab stop will be set to the last column).
The change shouldn't have any effect on legacy code, because the
GetForwardTab
method is only used in VT mode, as far as I can tell - the legacy tab handling is a completely separate implementation.I'd be happy to provide a PR for this if nobody disagrees with the suggested fix.
The text was updated successfully, but these errors were encountered: