Skip to content

Commit

Permalink
Fix OSC8 termination over the PTY after SGR 0 (#7608)
Browse files Browse the repository at this point in the history
We were prematurely clearing the hyperlink ID by resetting the
_lastTextAttributes. We should only clear the fields we want
cleared.

Fixes #7597.
  • Loading branch information
PankajBhojwani committed Sep 11, 2020
1 parent 892cf05 commit 88d1527
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/renderer/vt/paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,14 @@ using namespace Microsoft::Console::Types;
// If both the FG and BG should be the defaults, emit a SGR reset.
if (fg.IsDefault() && bg.IsDefault() && !(lastFg.IsDefault() && lastBg.IsDefault()))
{
// SGR Reset will clear all attributes.
// SGR Reset will clear all attributes (except hyperlink ID) - which means
// we cannot reset _lastTextAttributes by simply doing
// _lastTextAttributes = {};
// because we want to retain the last hyperlink ID
RETURN_IF_FAILED(_SetGraphicsDefault());
_lastTextAttributes = {};
_lastTextAttributes.SetDefaultBackground();
_lastTextAttributes.SetDefaultForeground();
_lastTextAttributes.SetDefaultMetaAttrs();
lastFg = {};
lastBg = {};
}
Expand Down Expand Up @@ -269,9 +274,14 @@ using namespace Microsoft::Console::Types;
// We can't reset FG and BG to default individually.
if ((fg.IsDefault() && !lastFg.IsDefault()) || (bg.IsDefault() && !lastBg.IsDefault()))
{
// SGR Reset will clear all attributes.
// SGR Reset will clear all attributes (except hyperlink ID) - which means
// we cannot reset _lastTextAttributes by simply doing
// _lastTextAttributes = {};
// because we want to retain the last hyperlink ID
RETURN_IF_FAILED(_SetGraphicsDefault());
_lastTextAttributes = {};
_lastTextAttributes.SetDefaultBackground();
_lastTextAttributes.SetDefaultForeground();
_lastTextAttributes.SetDefaultMetaAttrs();
lastFg = {};
lastBg = {};
}
Expand Down

0 comments on commit 88d1527

Please sign in to comment.