-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Windows console fixes #12064
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
Windows console fixes #12064
Conversation
Corrected integer size passed to Windows Corrected DisableEcho / SetRawTerminal to not modify state Cleaned up and made routines more idiomatic Corrected raw mode state bits Removed duplicate IsTerminal Corrected off-by-one error Minor idiomatic change Signed-off-by: Brendan Dixon <brendand@microsoft.com>
@icecrime @tiborvass @jfrazelle Folks meet @brendandixon, our new ANSI emulation maintainer. This change reduces panics on terminal-attached sessions a great deal (for example I haven't got one today 😄) as far as I can tell and fixes several other minor displaying problems. I really appreciate if you folks can review and try out. I think we should take this for 1.6. (I know, this is short notice but this observably improves the quality). |
does this fix the panics? |
@jfrazelle as far as I can tell, yeah "many of them", however we do not have a systematic way to test and we've seen that not all repro steps causes panics in everybody's computer. I remember @icecrime/@tiborvass were observing certain panics with repro steps. That's why I'd love if you guys try it out. As I said, this visibly reduces panics on terminal attach. |
My hat off to you guys: it does fix the reproducible panics I encountered. 😮 LGTM 👍 |
Hey @unclejack, since you're the buffer master, would you mind taking a peek at the ANSI code (that this PR modifies) sometime? There are bunch of weird things it's doing :( |
I will address them. It's going to take a couple/ three days.
|
I can attest that this does not make things worse LGTM |
also thanks so much for the hustle |
Well, that sets a high bar. :) Brendan
|
Also @stevvooe fixed similar bufio bug in pull. |
inFd = file.Fd() | ||
isTerminalIn = IsTerminal(inFd) | ||
} | ||
isTerminalIn = IsConsole(inFd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line highlights a nit I have with renaming the Terminal stuff in _windows to Console...we just end up with a mix at the two levels of abstraction that makes the code no clearer...arguably more confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the reason I renamed them is that the concepts are sufficiently separate to avoid mixed assumptions. Consoles in Windows are only somewhat like Terminals (TTYs) in Unix / Linux. Further, since the code is part of the abstraction layer for Windows, it made most sense to use Windows-centric terms at that level and buried within the Windows files.
I'm not married to these ideas, but they motivated the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk
LGTM |
I should note that |
We plan other changes to clean-up, simplify, and improve the code. I'll merge these suggestions with those changes. |
LGTM |
return winconsole.SetConsoleMode(fd, state.mode) | ||
mode := state.mode | ||
mode &^= winconsole.ENABLE_ECHO_INPUT | ||
mode |= winconsole.ENABLE_PROCESSED_INPUT | winconsole.ENABLE_LINE_INPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these options don't mutate state.mode
anymore, is this correct @brendandixon, @ahmetalpbalkan? I wonder if this can be a possible cause of the term resizing regression that we just detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code has had window resize issues. These changes did not introduce them nor expose them. The intention here is to honor the "contract" of DisableEcho as implemented by other terminal code.
Corrected integer size passed to Windows
Corrected DisableEcho / SetRawTerminal to not modify state
Cleaned up and made routines more idiomatic
Corrected raw mode state bits
Removed duplicate IsTerminal
Corrected off-by-one error
Minor idiomatic change
Signed-off-by: Brendan Dixon brendand@microsoft.com