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 collision of osc-8 id #1507

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
<li>Add better bell sound (#1378)</li>
<li>Add config entry to configure behaviour on exit from search mode</li>
<li>Update of contour.desktop file (#1423)</li>
<li>Fixed forwarding of input while in normal mode (#1468)</li>
<li>Fixes forwarding of input while in normal mode (#1468)</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
15 changes: 9 additions & 6 deletions src/vtbackend/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,16 +1403,19 @@ void Screen<Cell>::hyperlink(string id, string uri)
_cursor.hyperlink = {};
else
{
if (!id.empty())
auto cacheId { std::move(id) };
if (!cacheId.empty())
{
_cursor.hyperlink = _terminal->hyperlinks().hyperlinkIdByUserId(id);
cacheId += 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 @@ -2981,9 +2984,9 @@ namespace impl
id = p->second;

if (pos + 1 != value.size())
screen.hyperlink(id, value.substr(pos + 1));
screen.hyperlink(std::move(id), value.substr(pos + 1));
else
screen.hyperlink(string { id }, string {});
screen.hyperlink(std::move(id), string {});

return ApplyResult::Ok;
}
Expand Down
Loading