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

Fix collision of osc-8 id #1507

merged 1 commit into from
Jun 20, 2024

Conversation

Yaraslaut
Copy link
Member

Closes #1499

@github-actions github-actions bot added the VT: Backend Virtual Terminal Backend (libterminal API) label May 23, 2024
@@ -1470,19 +1470,13 @@ 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)
Copy link
Member

Choose a reason for hiding this comment

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

Thank you, @Yaraslaut, for this PR.

I think, if this parameter is not to be used anymore, we should get rid of it. We could then also give this function a more actionable name, to make it more clear on the caller side, what this function is intending to do.

Copy link

Choose a reason for hiding this comment

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

If you're not using the id parameter, doesn't that mean you'll fail to highlight both parts of the hyperlink when it gets split (e.g. in something like a wrapped tmux pane)?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you're not using the id parameter, doesn't that mean you'll fail to highlight both parts of the hyperlink when it gets split (e.g. in something like a wrapped tmux pane)?

Not sure about tmux, but every link has its own unique id and after wrap everything is alright:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, @Yaraslaut, for this PR.

I think, if this parameter is not to be used anymore, we should get rid of it. We could then also give this function a more actionable name, to make it more clear on the caller side, what this function is intending to do.

I didn't change the signature to have osc-8 compliant function for hyperlinks, if you think that we do not need to keep it that way, i can propagate this change in the code further

Copy link

Choose a reason for hiding this comment

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

The point is that a multiplexer might have to redraw the wrapped link itself, potentially somewhere in the middle of the screen. In that case you'll end up with two links with the same id, which the multiplexer will output something like this:

printf '\e[10C\e]8;id=123;http://example.com/\e\\WRAPPE\e]8;;\e\\\n\e]8;id=123;http://example.com/\e\\D_LINK\e]8;;\e\\\n'

Hovering over either half of the link should underline both parts. That's the whole reason for the id parameter.

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 see, not sure which of the behaviours we want to break then, i would prefer instead of the id of the link to have some flag indicating that we need to connect the link with previous one, otherwise i have no idea how this can be overcome, any ideas @j4james, @christianparpart ?

Copy link

Choose a reason for hiding this comment

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

What I was trying to explain in #1499 (comment), and what the spec says, is that you should combine the id with the url in order to get a unique identifier for each hyperlink. If you've got two links on the page with the same id and url, they should both be underlined together. If you've got two links with the same id, but with different urls, then they won't be underlined together, and should have separate entries in your cache. The bug in #1499 should not be possible if you follow this approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated PR @j4james, thanks a lot for taking a time and explained what I was missing in my previous fix. Hope that now everything is correct :)

Copy link

Choose a reason for hiding this comment

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

@Yaraslaut I don't know the code base, so I can't really review it properly, but the latest changes look good to me.

@Yaraslaut Yaraslaut requested a review from j4james June 1, 2024 18:30
Signed-off-by: Christian Parpart <christian@parpart.family>
@christianparpart christianparpart merged commit adaac91 into master Jun 20, 2024
24 of 25 checks passed
@christianparpart christianparpart deleted the fix/osc8_link_id branch June 20, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VT: Backend Virtual Terminal Backend (libterminal API)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSC-8 link storage(?) broken for links generated with aerc colorize
3 participants