Fix missing call to UpdateViewport::UpdateViewport during tearout (#15175)

This bug causes AtlasEngine to render buffer contents with an incorrect
`cellCount`, which may either cause it to draw the contents only
partially, or potentially access the TextBuffer contents out of bounds.

`EnablePainting` sets the `_viewport` to the current viewport for some
unfortunate (and quite buggy/incorrect) caching purposes, which causes
`_CheckViewportAndScroll()` to think that the viewport hasn't changed
in the new window. We can ensure `_CheckViewportAndScroll()` works
by also setting `_forceUpdateViewport` to `true`.

Part of #14957

## PR Checklist
* Tear out a tab from a smaller window to a larger window
* Renderer contents adept to the larger window size 

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
This commit is contained in:
Leonard Hecker
2023-04-25 23:32:44 +02:00
committed by GitHub
parent 7e9f09f495
commit adbe4a0d0c
3 changed files with 4 additions and 3 deletions

View File

@@ -251,8 +251,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Bubble this up, so our new control knows how big we want the font.
_FontSizeChangedHandlers(actualNewSize.width, actualNewSize.height, true);
// Turn the rendering back on now that we're ready to go.
_renderer->EnablePainting();
// The renderer will be re-enabled in Initialize
_AttachedHandlers(*this, nullptr);
}

View File

@@ -638,6 +638,7 @@ void Renderer::EnablePainting()
// When the renderer is constructed, the initial viewport won't be available yet,
// but once EnablePainting is called it should be safe to retrieve.
_viewport = _pData->GetViewport();
_forceUpdateViewport = true;
// When running the unit tests, we may be using a render without a render thread.
if (_pThread)

View File

@@ -131,7 +131,7 @@ namespace Microsoft::Console::Render
std::function<void()> _pfnFrameColorChanged;
std::function<void()> _pfnRendererEnteredErrorState;
bool _destructing = false;
bool _forceUpdateViewport = true;
bool _forceUpdateViewport = false;
#ifdef UNIT_TESTING
friend class ConptyOutputTests;