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

Fix text selection while new lines are being printed when history buffer is full #10749

Merged
13 commits merged into from
Aug 20, 2021
7 changes: 7 additions & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,13 @@ void Terminal::_AdjustCursorPosition(const COORD proposedPosition)
_buffer->IncrementCircularBuffer();
proposedCursorPosition.Y--;
rowsPushedOffTopOfBuffer++;

// Update our selection too, so it doesn't move as the buffer is cycled
if (_selection)
{
_selection->start.Y -= 1;
Copy link
Member

Choose a reason for hiding this comment

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

What if the selection starts to go off the top of the screen (Y=0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, if start.Y is at 0, we only reduce end.Y (if end.Y is greater than 0). If both are at 0, we clear the selection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: if we're only reducing end.Y, then we also set start.X = 0 to keep the block selection

_selection->end.Y -= 1;
}
}

// manually erase our pattern intervals since the locations have changed now
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/base/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,16 @@ void Renderer::TriggerScroll(const COORD* const pcoordDelta)
// - <none>
void Renderer::TriggerCircling()
{
const auto rects = _GetSelectionRects();

for (IRenderEngine* const pEngine : _rgpEngines)
{
bool fEngineRequestsRepaint = false;
HRESULT hr = pEngine->InvalidateCircling(&fEngineRequestsRepaint);
LOG_IF_FAILED(hr);

LOG_IF_FAILED(pEngine->InvalidateSelection(rects));

if (SUCCEEDED(hr) && fEngineRequestsRepaint)
{
LOG_IF_FAILED(_PaintFrameForEngine(pEngine));
Expand Down