Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement TextBuffer::Reflow #15701

Merged
merged 16 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions src/host/VtIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,40 +463,6 @@ void VtIo::SendCloseEvent()
}
}

// Method Description:
// - Tell the vt renderer to begin a resize operation. During a resize
// operation, the vt renderer should _not_ request to be repainted during a
// text buffer circling event. Any callers of this method should make sure to
// call EndResize to make sure the renderer returns to normal behavior.
// See GH#1795 for context on this method.
// Arguments:
// - <none>
// Return Value:
// - <none>
void VtIo::BeginResize()
{
if (_pVtRenderEngine)
{
_pVtRenderEngine->BeginResizeRequest();
}
}

// Method Description:
// - Tell the vt renderer to end a resize operation.
// See BeginResize for more details.
// See GH#1795 for context on this method.
// Arguments:
// - <none>
// Return Value:
// - <none>
void VtIo::EndResize()
{
if (_pVtRenderEngine)
{
_pVtRenderEngine->EndResizeRequest();
}
}

#ifdef UNIT_TESTING
// Method Description:
// - This is a test helper method. It can be used to trick VtIo into responding
Expand Down
3 changes: 0 additions & 3 deletions src/host/VtIo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ namespace Microsoft::Console::VirtualTerminal
void CloseInput();
void CloseOutput();

void BeginResize();
void EndResize();

#ifdef UNIT_TESTING
void EnableConptyModeForTests(std::unique_ptr<Microsoft::Console::Render::VtEngine> vtRenderEngine);
#endif
Expand Down
13 changes: 0 additions & 13 deletions src/host/screenInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,19 +1513,6 @@ NT_CATCH_RETURN()
auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
auto status = STATUS_SUCCESS;

// If we're in conpty mode, suppress any immediate painting we might do
// during the resize.
if (gci.IsInVtIoMode())
{
gci.GetVtIo()->BeginResize();
}
auto endResize = wil::scope_exit([&] {
if (gci.IsInVtIoMode())
{
gci.GetVtIo()->EndResize();
}
});
Comment on lines -1498 to -1507
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working on another PR I realized that this special behavior is only here for TextBuffer::Reflow, because that one used to use NewlineCursor which calls IncrementCircularBuffer which calls Renderer::TriggerFlush which calls VtEngine::InvalidateFlush which then set pForcePaint = false if BeginResize was called.

In short: This block prevents TextBuffer::Reflow from setting pForcePaint to true.

...and the new code doesn't call IncrementCircularBuffer anymore so that's moot.


// cancel any active selection before resizing or it will not necessarily line up with the new buffer positions
Selection::Instance().ClearSelection();

Expand Down
16 changes: 4 additions & 12 deletions src/renderer/vt/invalidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,11 @@ CATCH_RETURN();
// - S_OK
[[nodiscard]] HRESULT VtEngine::InvalidateFlush(_In_ const bool circled, _Out_ bool* const pForcePaint) noexcept
{
// If we're in the middle of a resize request, don't try to immediately start a frame.
if (_inResizeRequest)
{
*pForcePaint = false;
}
else
{
*pForcePaint = true;
*pForcePaint = true;

// Keep track of the fact that we circled, we'll need to do some work on
// end paint to specifically handle this.
_circled = circled;
}
// Keep track of the fact that we circled, we'll need to do some work on
// end paint to specifically handle this.
_circled = circled;

// If we flushed for any reason other than circling (i.e, a sequence that we
// didn't understand), we don't need to push the buffer out on EndPaint.
Expand Down
29 changes: 0 additions & 29 deletions src/renderer/vt/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ VtEngine::VtEngine(_In_ wil::unique_hfile pipe,
_terminalOwner{ nullptr },
_newBottomLine{ false },
_deferredCursorPos{ INVALID_COORDS },
_inResizeRequest{ false },
_trace{},
_bufferLine{},
_buffer{},
Expand Down Expand Up @@ -446,34 +445,6 @@ HRESULT VtEngine::RequestCursor() noexcept
return S_OK;
}

// Method Description:
// - Tell the vt renderer to begin a resize operation. During a resize
// operation, the vt renderer should _not_ request to be repainted during a
// text buffer circling event. Any callers of this method should make sure to
// call EndResize to make sure the renderer returns to normal behavior.
// See GH#1795 for context on this method.
// Arguments:
// - <none>
// Return Value:
// - <none>
void VtEngine::BeginResizeRequest()
{
_inResizeRequest = true;
}

// Method Description:
// - Tell the vt renderer to end a resize operation.
// See BeginResize for more details.
// See GH#1795 for context on this method.
// Arguments:
// - <none>
// Return Value:
// - <none>
void VtEngine::EndResizeRequest()
{
_inResizeRequest = false;
}

// Method Description:
// - Configure the renderer for the resize quirk. This changes the behavior of
// conpty to _not_ InvalidateAll the entire viewport on a resize operation.
Expand Down
1 change: 0 additions & 1 deletion src/renderer/vt/vtrenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ namespace Microsoft::Console::Render
Microsoft::Console::VirtualTerminal::VtIo* _terminalOwner;

Microsoft::Console::VirtualTerminal::RenderTracing _trace;
bool _inResizeRequest{ false };

std::optional<til::CoordType> _wrappedRow{ std::nullopt };

Expand Down