diff --git a/src/renderer/atlas/AtlasEngine.h b/src/renderer/atlas/AtlasEngine.h index f85b5ab185bc..12ab6a82db0b 100644 --- a/src/renderer/atlas/AtlasEngine.h +++ b/src/renderer/atlas/AtlasEngine.h @@ -686,6 +686,11 @@ namespace Microsoft::Console::Render return false; } + // We need to backup _pos/_size in case our resize below exceeds _maxArea. + // In that case we have to restore _pos/_size so that if _maxArea is increased + // (window resize for instance), we can pick up were we previously left off. + const auto pos = _pos; + _pos.x += _tileSize.x; if (_pos.x <= _limit.x) { @@ -717,10 +722,19 @@ namespace Microsoft::Console::Render _size.y *= 2; _pos.x = 0; } - _limit = { gsl::narrow_cast(_size.x - _tileSize.x), gsl::narrow_cast(_size.y - _tileSize.y) }; - _originX = _pos.x; _updateCanGenerate(); + if (_canGenerate) + { + _limit = { static_cast(_size.x - _tileSize.x), static_cast(_size.y - _tileSize.y) }; + _originX = _pos.x; + } + else + { + _size = size; + _pos = pos; + } + return _canGenerate; }