terminal: Hyperlinks with the same ID and different URIs collide when they shouldn't
In Windows Terminal Preview 1.4.2652.0. Hyperlinks support is a great addition, but from my understanding there is a bug with how links IDs are parsed and handled.
Character cells that have the same target URI and the same nonempty id are always underlined together on mouseover. The same id is only used for connecting character cells whose URIs is also the same. Character cells pointing to different URIs should never be underlined together when hovering over. (Source: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#hover-underlining-and-the-id-parameter )
But testing the same ID with different URIs shows Windows Terminal is grouping them together and using the URI of the last one for both :
echo -e '\e]8;id=a;http://www.microsoft.com/\aMicrosoft\e]8;;\a \e]8;id=a;http://www.google.com/\aGoogle\e]8;;\a'
Even different IDs are grouped together if they are not numbers:
echo -e '\e]8;id=a;http://www.microsoft.com/\aMicrosoft\e]8;;\a \e]8;id=b;http://www.google.com/\aGoogle\e]8;;\a'
While the page about hyperlinks explicitely shows and states that these IDs are strings, not numbers:
params is an optional list of key=value assignments, separated by the : character. Example: id=xyz123:foo=bar:baz=quux.
Complex apps that display data that might itself contain OSC 8 hyperlinks (such as terminal multiplexers, less -R) should do the following: If the encountered OSC 8 hyperlink already has an id, they should prefix it with some static string, or if multiple windows/panes are supported by the app, a prefix that’s unique to that window/pane to prevent conflict with other windows/panes.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 30 (16 by maintainers)
Commits related to this issue
- Hash the URI as part of the hyperlink ID It turns out that we missed part of the OSC 8 spec which indicated that _hyperlinks with the same ID but different URIs are logically distinct._ > Character ... — committed to microsoft/terminal by DHowett 4 years ago
- Hash the URI as part of the hyperlink ID (#7940) It turns out that we missed part of the OSC 8 spec which indicated that _hyperlinks with the same ID but different URIs are logically distinct._ >... — committed to microsoft/terminal by DHowett 4 years ago
- Hash the URI as part of the hyperlink ID (#7940) It turns out that we missed part of the OSC 8 spec which indicated that _hyperlinks with the same ID but different URIs are logically distinct._ > Ch... — committed to microsoft/terminal by DHowett 4 years ago
Because in that grid() function, the whole tile of each ANSI-art icon + label acts as a single hyperlink, so these links span several lines and are entertwined with other grid cells on each line. Not providing IDs would work when you click, but wouldn’t have the hover highlight on the whole tile on mouse over.
I believe that would be against specs, incompatible behavior with other terminals and risky as new output could modify a previous link, including some link shown by another utility in the same scrollback buffer if ID collision occurs between utilities in the same shell. Using {id,uri} as the unique ID means you might have the highlight effect spanning several outputs if ids and uris collide, but at least it’s only a visual glitch, you can’t have an utility take over another utility’s output targets.