refactor: remove internal ID for URL sequences#2416
refactor: remove internal ID for URL sequences#2416joelim-work wants to merge 1 commit intogokcehan:masterfrom
Conversation
|
Yeah, However, according to the reference,
|
|
That advice appears to be referring to the case of partially redrawing a hyperlink, where a custom ID is used to indicate that the new text is part of the original hyperlink and not a new one. But I admit that I'm not an expert on this matter, so I will just ask this. Do you know of an actual example where assigning a custom ID has an improvement over leaving the ID blank? The In fact, the current implementation in # Example Markdown
A link:
[Example](https://example.com)
Another link:
[Example](https://example.com)
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
Yet another link:
[Example](https://example.com) |
|
I am no expert either. The ref only really talks about 'adjacent' links with the same URI. These are also included in the linked example file. Maybe @veltza can help us here. |
|
Based on my tests, terminal emulators handle hyperlinks with the same URL but no ID in three different ways:
I debugged this PR with my And you open For this reason, hyperlinks may behave slightly differently in |
|
Tcell maintains an internal buffer where each cell has its own style information. When drawing the UI, Tcell will only send the OSC 8 sequence when the URL style changes between cells, in other words it will merge adjacent cells a single hyperlink. One interesting thing to note is that Tcell skips any cells if they have not changed (for the purposes of writing updates to the terminal), so in theory if a portion of the text is changed, a new OSC 8 sequence will be sent for only that portion, and that could be treated as a different hyperlink from the original one. This is the reason behind the advice for always assigning an ID so that the old and new text are forcibly linked together (CMIIW). However I think it would make more sense if Tcell could detect and resend the entire hyperlink if any portion of it changes, so that manually assigning IDs like this is not necessary. My understanding for IDs was that it is mainly used to mark separate sections of text as linked such as below: Anyway I think there are three solutions on how to deal with blank IDs:
I still lean towards the first one, provided it doesn't cause any issues, but I am probably ultimately fine with whichever solution depending on feedback from users (this is a somewhat niche feature so I'm not sure if there will be much feedback anyway). EDIT: For the initial |
Thinking about it, I'd also say let's stick to the passthrough method. It is probably not worth it to over-engineer such a niche feature. I also doubt that there will be any user feedback regarding this. If there is, we can discuss this again. |




OSC 8support #2243Now that Tcell has been upgraded to v3 in #2286, I think we no longer need the autogenerated ID workaround since Tcell now handles spaces correctly.