Skip to content

Commit 67f1ee9

Browse files
committed
Stop leaking CPR sequences
1 parent c7c742c commit 67f1ee9

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/terminal/parser/InputStateMachineEngine.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,18 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
391391
//
392392
// Focus events in conpty are special, so don't flush those through either.
393393
// See GH#12799, GH#12900 for details
394-
if (_pDispatch->IsVtInputEnabled() &&
395-
id != CsiActionCodes::Win32KeyboardInput &&
396-
id != CsiActionCodes::FocusIn &&
397-
id != CsiActionCodes::FocusOut)
398-
{
399-
return false;
400-
}
394+
const auto vtInputEnabled = _pDispatch->IsVtInputEnabled();
401395

402396
switch (id)
403397
{
404398
case CsiActionCodes::MouseDown:
405399
case CsiActionCodes::MouseUp:
406400
{
401+
if (vtInputEnabled)
402+
{
403+
return false;
404+
}
405+
407406
DWORD buttonState = 0;
408407
DWORD eventFlags = 0;
409408
const auto firstParameter = parameters.at(0).value_or(0);
@@ -423,6 +422,7 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
423422
// Else, fall though to the _GetCursorKeysModifierState handler.
424423
if (_captureNextCursorPositionReport.exchange(false, std::memory_order_relaxed))
425424
{
425+
OutputDebugStringA("MoveCursor\n");
426426
_pDispatch->MoveCursor(parameters.at(0), parameters.at(1));
427427
return true;
428428
}
@@ -432,6 +432,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
432432
{
433433
return false;
434434
}
435+
if (vtInputEnabled)
436+
{
437+
return false;
438+
}
435439
[[fallthrough]];
436440
case CsiActionCodes::ArrowUp:
437441
case CsiActionCodes::ArrowDown:
@@ -443,6 +447,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
443447
case CsiActionCodes::CSI_F2:
444448
case CsiActionCodes::CSI_F4:
445449
{
450+
if (vtInputEnabled)
451+
{
452+
return false;
453+
}
446454
short vkey = 0;
447455
if (_GetCursorKeysVkey(id, vkey))
448456
{
@@ -453,6 +461,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
453461
}
454462
case CsiActionCodes::Generic:
455463
{
464+
if (vtInputEnabled)
465+
{
466+
return false;
467+
}
456468
short vkey = 0;
457469
if (_GetGenericVkey(parameters.at(0), vkey))
458470
{
@@ -462,6 +474,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
462474
return true;
463475
}
464476
case CsiActionCodes::CursorBackTab:
477+
if (vtInputEnabled)
478+
{
479+
return false;
480+
}
465481
_WriteSingleKey(VK_TAB, SHIFT_PRESSED);
466482
return true;
467483
case CsiActionCodes::FocusIn:

0 commit comments

Comments
 (0)