diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 2cc3fef16..ac7bf1b07 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -804,6 +804,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } + // Convert our new dimensions to characters + const auto viewInPixels = Viewport::FromDimensions({ 0, 0 }, + { static_cast(size.cx), static_cast(size.cy) }); + const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels); + const auto currentVP = _terminal->GetViewport(); + + // Don't actually resize if viewport dimensions didn't change + if (vp.Height() == currentVP.Height() && vp.Width() == currentVP.Width()) + { + return; + } + _terminal->ClearSelection(); // Tell the dx engine that our window is now the new size. @@ -812,11 +824,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation // Invalidate everything _renderer->TriggerRedrawAll(); - // Convert our new dimensions to characters - const auto viewInPixels = Viewport::FromDimensions({ 0, 0 }, - { static_cast(size.cx), static_cast(size.cy) }); - const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels); - // If this function succeeds with S_FALSE, then the terminal didn't // actually change size. No need to notify the connection of this no-op. const HRESULT hr = _terminal->UserResize({ vp.Width(), vp.Height() });