File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ SCREEN_INFORMATION::SCREEN_INFORMATION(
68
68
LineChar[3 ] = UNICODE_BOX_DRAW_LIGHT_VERTICAL;
69
69
LineChar[4 ] = UNICODE_BOX_DRAW_LIGHT_UP_AND_RIGHT;
70
70
LineChar[5 ] = UNICODE_BOX_DRAW_LIGHT_UP_AND_LEFT;
71
+
72
+ // Check if VT mode is enabled. Note that this can be true w/o calling
73
+ // SetConsoleMode, if VirtualTerminalLevel is set to !=0 in the registry.
71
74
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals ().getConsoleInformation ();
72
75
if (gci.GetVirtTermLevel () != 0 )
73
76
{
@@ -132,6 +135,16 @@ SCREEN_INFORMATION::~SCREEN_INFORMATION()
132
135
133
136
const NTSTATUS status = pScreen->_InitializeOutputStateMachine ();
134
137
138
+ if (pScreen->InVTMode ())
139
+ {
140
+ // microsoft/terminal#411: If VT mode is enabled, lets construct the
141
+ // VT tab stops. Without this line, if a user has
142
+ // VirtualTerminalLevel set, then
143
+ // SetConsoleMode(ENABLE_VIRTUAL_TERMINAL_PROCESSING) won't set our
144
+ // tab stops, because we're never going from vt off -> on
145
+ pScreen->SetDefaultVtTabStops ();
146
+ }
147
+
135
148
if (NT_SUCCESS (status))
136
149
{
137
150
*ppScreen = pScreen;
Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ class ScreenBufferTests
180
180
TEST_METHOD (RestoreDownAltBufferWithTerminalScrolling);
181
181
182
182
TEST_METHOD (ClearAlternateBuffer);
183
+
184
+ TEST_METHOD (InitializeTabStopsInVTMode);
183
185
};
184
186
185
187
void ScreenBufferTests::SingleAlternateBufferCreationTest ()
@@ -4347,3 +4349,25 @@ void ScreenBufferTests::ClearAlternateBuffer()
4347
4349
4348
4350
VerifyText (siMain.GetTextBuffer ());
4349
4351
}
4352
+
4353
+ void ScreenBufferTests::InitializeTabStopsInVTMode ()
4354
+ {
4355
+ // This is a test for microsoft/terminal#1189. Refer to that issue for more
4356
+ // context
4357
+
4358
+ auto & g = ServiceLocator::LocateGlobals ();
4359
+ auto & gci = g.getConsoleInformation ();
4360
+
4361
+ VERIFY_IS_FALSE (gci.GetActiveOutputBuffer ().AreTabsSet ());
4362
+
4363
+ // Enable VT mode before we construct the buffer. This emulates setting the
4364
+ // VirtualTerminalLevel reg key before launching the console.
4365
+ gci.SetVirtTermLevel (1 );
4366
+
4367
+ // Clean up the old buffer, and re-create it. This new buffer will be
4368
+ // created as if the VT mode was always on.
4369
+ m_state->CleanupGlobalScreenBuffer ();
4370
+ m_state->PrepareGlobalScreenBuffer ();
4371
+
4372
+ VERIFY_IS_TRUE (gci.GetActiveOutputBuffer ().AreTabsSet ());
4373
+ }
You can’t perform that action at this time.
0 commit comments