-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Make all console output modes more strictly buffer state #14735
Conversation
I think this is logically the right approach to take, in that the "rules" are straightforward, so the behavior is easily predictable. However, my one concern is with the |
Totally cool with this. Alt buffer being a Thanks for doing this. |
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.
Approved with comment - I expect that I've missed something, and there's a second reviewer yet required. 😄
|
||
if (ServiceLocator::LocateGlobals().pRender != nullptr) | ||
{ | ||
ServiceLocator::LocateGlobals().pRender->TriggerRedrawAll(); |
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.
Do we need to retain this logic? We might miss a global repaint if we don't, and grid lines that had been written will not appear on demand.
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 redraw was also being done in the SetConsoleOutputModeImpl
method, so this code was never really necessary. See here:
Lines 443 to 454 in 0eff8c0
// if we changed rendering modes then redraw the output buffer, | |
// but only do this if we're not in conpty mode. | |
if (!gci.IsInVtIoMode() && | |
(WI_IsFlagSet(dwNewMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING) != WI_IsFlagSet(dwOldMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING) || | |
WI_IsFlagSet(dwNewMode, ENABLE_LVB_GRID_WORLDWIDE) != WI_IsFlagSet(dwOldMode, ENABLE_LVB_GRID_WORLDWIDE))) | |
{ | |
auto* pRender = ServiceLocator::LocateGlobals().pRender; | |
if (pRender) | |
{ | |
pRender->TriggerRedrawAll(); | |
} | |
} |
I should also mention that I wrote some little test apps similar to the functional tests, but which render output to visually confirm the modes are working as expected. And when the ENABLE_LVB_GRID_WORLDWIDE
mode is toggled, the screen was definitely being refreshed, with the grid line disappearing and reappearing.
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.
Love the changeset. But @DHowett makes a valid point about the renderer invalidation. I don't know what ENABLE_LVB_GRID_WORLDWIDE
does (I've never tried it), but I imagine that it requires an invalidation when the setting changes.
That's all I need. Thank you! |
Hello @DHowett! Because this pull request has the 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 (
|
I know it's a bit late now, since we're merged, but just to be clear, my concern regarding the Technically the current behavior isn't really inheritance anyway, but it's probably close enough for most use cases that are expecting that. But after this PR, you'll need to explicitly set the mode in every buffer you create (not counting the alt buffer). That's assuming you want it changed from the default, i.e. you want to turn it on in cohost, or turn it off in Windows Terminal. Now I wouldn't have thought there were a lot of apps using |
Two weeks ago, I took a note to document this breaking change somewhere. I finally did that here: https://github.com/microsoft/terminal/wiki/Console:-Potential-Breaking-Changes I'm going to try to make sure we track this stuff a little better, because the Windows release cycle has gotten somewhat longer and it means we accumulate more things like this before people see them. |
The original console output modes were considered attributes of the
buffer, while later additions were treated as global state, and yet both
were accessed via the same buffer-based API. This could result in the
reported modes being out of sync with the way the system was actually
behaving, and a call to
SetConsoleMode
without updating anything couldstill trigger unpredictable changes in behavior.
This PR attempts to address that problem by making all modes part of the
buffer state, and giving them predictable default values.
While this won't solve all the tmux layout-breaking issues in #6987, it
does at least fix one case which was the result of an unexpected change
in the
DISABLE_NEWLINE_AUTO_RETURN
mode.All access to the output modes is now done via the
OutputMode
field inSCREEN_INFORMATION
. The fields that were tracking global state in theSettings
class (_fAutoReturnOnNewline
and_fRenderGridWorldwide
)have now been removed.
We still have a global
_dwVirtTermLevel
field, though, but that nowserves as a default value for the
ENABLE_VIRTUAL_TERMINAL_PROCESSING
mode when creating a new buffer. It's enabled for conpty mode, and when
the VT level in the registry is not 0. That default doesn't change.
For the VT alternate buffer, things works slightly differently, since
there is an expectation that VT modes are global. So when creating an
alt buffer, we copy the current modes from the main buffer, and when
it's closed, we copy them back again.
Validation Steps Performed
I've manually confirmed that this fixes the problem described in issue
#14690. I've also added a basic feature test that confirms the modes are
initialized as expected when creating new buffers, and changes to the
modes in one buffer do not impact any other buffers.
Closes #14690