Closed skyzyx closed 2 years ago
Hey there! Thanks for reporting this issue
I think I've found the issue. The extra space is due to a u200B
character, also known as a ZERO_WIDTH_SPACE. This is a sort of a "hacky" workaround used to force text to render as links in non-hyperlink terminals.
I'm on Windows at the moment, and all this time, I have been testing the code on both VSCode and Windows Terminal. Windows Terminal provides full support for text hyperlinks while VSCode, although, it does not support text hyperlinks, it does render the non-text hyperlink perfectly, without the extra space.
On legacy Command Prompt, however, I found out that the text had a space after the opening parentheses, like you mentioned. I'm guessing it boils down to whether the terminal is properly able to render the u200B
character. Also, if you remove that Update: no such forced hyperlink, still plain textu200B
character from the code, the extra space will be removed all right, except there will be no clickable link - just plain text
Please note that this code was based on sindresorhus/terminal-link which used the u200B
character as well. This also means that code run using this NodeJS package, on a terminal which doesn't support linking, will produce the exact same output as above (see below image). This also means that this package does the exact same thing as sindresorhus' popular NPM package.
(image is from command prompt btw)
As of now, it works fine on most modern terminals, I haven't had a lot of different terminals/apps to test it, since I'm constrained to use only Windows. There might be a few problems around, and if you know how to fix them, I would surely appreciate the help!
A whole lot of research later, and after looking up some old issues on sindresorhus/terminal-link, I found that you don't actually need that u200B
character anymore. Looks like that character was placed purely for appearance purposes, in order to remove a specific VSCode bug, which has fixed in newer versions of VSCode. There were a lot of issues (and other referenced issues) on that repository regarding problems caused by that specific character.
When I decided to make this package, I had simply copied that character from that repo, not knowing what exactly it was and figured it was just another hacky workaround thing. I should probably have done a bit more research, I guess, heh.
And no, there is no way to actually "force hyperlinks" in a non-hyperlink supported terminal.
I'll remove the unwanted character in a future commit, but I'll wait until if you have anything to add to this.
This would be perfect. Thank you.
In Terminals which do not support linking, there is an extra space after the opening paren.
Code:
Display in Apple's Terminal.app (which does not support linking):
What's weird is that when I copy-paste it from the Terminal, the paste here in GitHub doesn't have it.
Any ideas?