Skip to content

Commit

Permalink
Fix collision of osc-8 id
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Jun 1, 2024
1 parent 2aa9cac commit e631221
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<li>Add SGRSAVE and SGRRESTORE VT sequences to save and restore SGR state (They intentionally conflict with XTPUSHSGR and XTPOPSGR)</li>
<li>Add extended word selection feature (#1023)</li>
<li>Update of contour.desktop file (#1423)</li>
<li>Fixes OSC-8 link id collision (#1499)</li>
<li>Fixed overlap of glyphs for long codepoints (#1349)</li>
<li>Fixed too verbose info during ssh session login (#1447)</li>
<li>Fixes corruption of sixel image on high resolution (#1049)</li>
Expand Down
19 changes: 12 additions & 7 deletions src/vtbackend/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,22 +1470,26 @@ void Screen<Cell>::setCurrentWorkingDirectory(string const& url)

template <typename Cell>
CRISPY_REQUIRES(CellConcept<Cell>)
void Screen<Cell>::hyperlink(string id, string uri)
void Screen<Cell>::hyperlink([[maybe_unused]] string id, string uri)
{
std::string cacheId { id };
if (uri.empty())
_cursor.hyperlink = {};
else
{

if (!id.empty())
{
_cursor.hyperlink = _terminal->hyperlinks().hyperlinkIdByUserId(id);
cacheId = id + uri;
_cursor.hyperlink = _terminal->hyperlinks().hyperlinkIdByUserId(cacheId);
if (_cursor.hyperlink != HyperlinkId {})
return;
}

// We ignore the user id since we need to ensure it's unique. We generate our own.
_cursor.hyperlink = _terminal->hyperlinks().nextHyperlinkId++;
_terminal->hyperlinks().cache.emplace(
_cursor.hyperlink, make_shared<HyperlinkInfo>(HyperlinkInfo { std::move(id), std::move(uri) }));
_cursor.hyperlink,
make_shared<HyperlinkInfo>(HyperlinkInfo { std::move(cacheId), std::move(uri) }));
}
// TODO:
// Care about eviction.
Expand Down Expand Up @@ -3880,9 +3884,10 @@ unique_ptr<ParserExtension> Screen<Cell>::hookSixel(Sequence const& seq)
aspectVertical,
aspectHorizontal,
transparentBackground ? RGBAColor { 0, 0, 0, 0 } : _terminal->colorPalette().defaultBackground,
_terminal->usePrivateColorRegisters() ? make_shared<SixelColorPalette>(
_terminal->maxSixelColorRegisters(), std::clamp(_terminal->maxSixelColorRegisters(), 0u, 16384u))
: _terminal->sixelColorPalette());
_terminal->usePrivateColorRegisters()
? make_shared<SixelColorPalette>(_terminal->maxSixelColorRegisters(),
std::clamp(_terminal->maxSixelColorRegisters(), 0u, 16384u))
: _terminal->sixelColorPalette());

return make_unique<SixelParser>(*_sixelImageBuilder, [this]() {
{
Expand Down
4 changes: 2 additions & 2 deletions src/vtbackend/Terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,8 @@ class Terminal
template <>
struct fmt::formatter<vtbackend::TraceHandler::PendingSequence>: fmt::formatter<std::string>
{
auto format(vtbackend::TraceHandler::PendingSequence const& pendingSequence,
format_context& ctx) -> format_context::iterator
auto format(vtbackend::TraceHandler::PendingSequence const& pendingSequence, format_context& ctx)
-> format_context::iterator
{
std::string value;
if (auto const* p = std::get_if<vtbackend::Sequence>(&pendingSequence))
Expand Down

0 comments on commit e631221

Please sign in to comment.