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

Initialize the text buffer with the default attributes on a resize #5792

Merged
9 commits merged into from
Apr 21, 2021
4 changes: 2 additions & 2 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
// old buffer's.
const auto oldBufferAttributes = _buffer->GetCurrentAttributes();
newTextBuffer = std::make_unique<TextBuffer>(bufferSize,
TextAttribute(),
TextAttribute{},
0, // temporarily set size to 0 so it won't render.
_buffer->GetRenderTarget());

Expand Down Expand Up @@ -281,7 +281,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
newViewportTop = oldRows.mutableViewportTop;
newVisibleTop = oldRows.visibleViewportTop;

// Restore the actve text attributes
// Restore the active text attributes
newTextBuffer->SetCurrentAttributes(oldBufferAttributes);
}
CATCH_RETURN();
Expand Down
14 changes: 9 additions & 5 deletions src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final

TEST_METHOD(HyperlinkIdConsistency);

TEST_METHOD(ResizeInitializeBufferWithDefaultAttrs);

private:
bool _writeCallback(const char* const pch, size_t const cch);
void _flushFirstFrame();
Expand Down Expand Up @@ -2900,11 +2902,13 @@ void ConptyRoundtripTests::ResizeInitializeBufferWithDefaultAttrs()
auto conhostGreenAttrs = TextAttribute();

// Conhost and Terminal store attributes in different bits.
conhostGreenAttrs.SetIndexedAttributes(std::nullopt,
{ static_cast<BYTE>(FOREGROUND_GREEN) });
// conhostGreenAttrs.SetIndexedAttributes(std::nullopt,
// { static_cast<BYTE>(FOREGROUND_GREEN) });
conhostGreenAttrs.SetIndexedBackground(FOREGROUND_GREEN);
auto terminalGreenAttrs = TextAttribute();
terminalGreenAttrs.SetIndexedAttributes(std::nullopt,
{ static_cast<BYTE>(XTERM_GREEN_ATTR) });
// terminalGreenAttrs.SetIndexedAttributes(std::nullopt,
// { static_cast<BYTE>(XTERM_GREEN_ATTR) });
terminalGreenAttrs.SetIndexedBackground(XTERM_GREEN_ATTR);

const size_t width = static_cast<size_t>(TerminalViewWidth);

Expand Down Expand Up @@ -2946,7 +2950,7 @@ void ConptyRoundtripTests::ResizeInitializeBufferWithDefaultAttrs()
{
Log::Comment(NoThrowString().Format(L"Checking row %d...", row));

VERIFY_IS_FALSE(tb.GetRowByOffset(row).GetCharRow().WasWrapForced());
VERIFY_IS_FALSE(tb.GetRowByOffset(row).WasWrapForced());

const bool hasChar = row < 3;
const auto actualDefaultAttrs = isTerminal ? TextAttribute() : defaultAttrs;
Expand Down
3 changes: 1 addition & 2 deletions src/host/screenInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,6 @@ bool SCREEN_INFORMATION::IsMaximizedY() const
RIPMSG2(RIP_WARNING, "Invalid screen buffer size (0x%x, 0x%x)", coordNewScreenSize.X, coordNewScreenSize.Y);
return STATUS_INVALID_PARAMETER;
}
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();

// First allocate a new text buffer to take the place of the current one.
std::unique_ptr<TextBuffer> newTextBuffer;
Expand All @@ -1422,7 +1421,7 @@ bool SCREEN_INFORMATION::IsMaximizedY() const
try
{
newTextBuffer = std::make_unique<TextBuffer>(coordNewScreenSize,
gci.GetDefaultAttributes(),
TextAttribute{},
Copy link
Member

Choose a reason for hiding this comment

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

whoa. this one scares me!! the session default attributes are more important in conhost than terminal. why the change?

Copy link
Member

Choose a reason for hiding this comment

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

oh but it defaults to {Default, Default} doesn't it

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I thought this was the way to do it post-#6506

Copy link
Member

Choose a reason for hiding this comment

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

ohhhhhhhhh okay

0,
_renderTarget); // temporarily set size to 0 so it won't render.
}
Expand Down