diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index fe89e839474..4efb3a5cfe1 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -1096,8 +1096,7 @@ bool AdaptDispatch::SetKeypadMode(const bool fApplicationMode) bool success = true; success = _pConApi->PrivateSetKeypadMode(fApplicationMode); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -1117,8 +1116,7 @@ bool AdaptDispatch::EnableWin32InputMode(const bool win32InputMode) bool success = true; success = _pConApi->PrivateEnableWin32InputMode(win32InputMode); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -1136,8 +1134,7 @@ bool AdaptDispatch::SetCursorKeysMode(const bool applicationMode) bool success = true; success = _pConApi->PrivateSetCursorKeysMode(applicationMode); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2045,8 +2042,7 @@ bool AdaptDispatch::EnableVT200MouseMode(const bool enabled) bool success = true; success = _pConApi->PrivateEnableVT200MouseMode(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2066,8 +2062,7 @@ bool AdaptDispatch::EnableUTF8ExtendedMouseMode(const bool enabled) bool success = true; success = _pConApi->PrivateEnableUTF8ExtendedMouseMode(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2087,8 +2082,7 @@ bool AdaptDispatch::EnableSGRExtendedMouseMode(const bool enabled) bool success = true; success = _pConApi->PrivateEnableSGRExtendedMouseMode(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2107,8 +2101,7 @@ bool AdaptDispatch::EnableButtonEventMouseMode(const bool enabled) bool success = true; success = _pConApi->PrivateEnableButtonEventMouseMode(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2128,8 +2121,7 @@ bool AdaptDispatch::EnableAnyEventMouseMode(const bool enabled) bool success = true; success = _pConApi->PrivateEnableAnyEventMouseMode(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2149,8 +2141,7 @@ bool AdaptDispatch::EnableAlternateScroll(const bool enabled) bool success = true; success = _pConApi->PrivateEnableAlternateScroll(enabled); - // If we're a conpty, always return false - if (_pConApi->IsConsolePty()) + if (_ShouldPassThroughInputModeChange()) { return false; } @@ -2341,3 +2332,22 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy return success; } + +// Routine Description: +// - Determines whether we should pass any sequence that manipulates +// TerminalInput's input generator through the PTY. It encapsulates +// a check for whether the PTY is in use. +// Return value: +// True if the request should be passed. +bool AdaptDispatch::_ShouldPassThroughInputModeChange() const +{ + // If we're a conpty, AND WE'RE IN VT INPUT MODE, always pass input mode requests + // The VT Input mode check is to work around ssh.exe v7.7, which uses VT + // output, but not Input. + // The original comment said, "Once the conpty supports these types of input, + // this check can be removed. See GH#4911". Unfortunately, time has shown + // us that SSH 7.7 _also_ requests mouse input and that can have a user interface + // impact on the actual connected terminal. We can't remove this check, + // because SSH <=7.7 is out in the wild on all versions of Windows <=2004. + return _pConApi->IsConsolePty() && _pConApi->PrivateIsVtInputEnabled(); +} diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index 64a1960ae7b..5aecde064f8 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -164,6 +164,8 @@ namespace Microsoft::Console::VirtualTerminal void _ResetTabStops() noexcept; void _InitTabStopsForWidth(const size_t width); + bool _ShouldPassThroughInputModeChange() const; + std::vector _tabStopColumns; bool _initDefaultTabStops = true;