Skip to content

Commit 0559c94

Browse files
committed
Stop leaking CPR sequences
1 parent c7c742c commit 0559c94

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/terminal/parser/InputStateMachineEngine.cpp

Lines changed: 22 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);
@@ -432,6 +431,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
432431
{
433432
return false;
434433
}
434+
if (vtInputEnabled)
435+
{
436+
return false;
437+
}
435438
[[fallthrough]];
436439
case CsiActionCodes::ArrowUp:
437440
case CsiActionCodes::ArrowDown:
@@ -443,6 +446,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
443446
case CsiActionCodes::CSI_F2:
444447
case CsiActionCodes::CSI_F4:
445448
{
449+
if (vtInputEnabled)
450+
{
451+
return false;
452+
}
446453
short vkey = 0;
447454
if (_GetCursorKeysVkey(id, vkey))
448455
{
@@ -453,6 +460,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
453460
}
454461
case CsiActionCodes::Generic:
455462
{
463+
if (vtInputEnabled)
464+
{
465+
return false;
466+
}
456467
short vkey = 0;
457468
if (_GetGenericVkey(parameters.at(0), vkey))
458469
{
@@ -462,6 +473,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
462473
return true;
463474
}
464475
case CsiActionCodes::CursorBackTab:
476+
if (vtInputEnabled)
477+
{
478+
return false;
479+
}
465480
_WriteSingleKey(VK_TAB, SHIFT_PRESSED);
466481
return true;
467482
case CsiActionCodes::FocusIn:

0 commit comments

Comments
 (0)