microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.82k stars 28.74k forks source link

Configure unicode highlight limit #139726

Open Zezombye opened 2 years ago

Zezombye commented 2 years ago

Unicode highlighting behaves normally when there are few special characters: image

However, when there are too many characters, vscode just gives up and does not highlight any:

Would it be possible to configure the limit before it gives up (does it take up that many resources to highlight them? in my test file there are 5337, syntax highlighting doesn't give up), and also to add an option to not have that popup so that I don't have to click the "x" each time?

Thanks :)

gjsjohnmurray commented 2 years ago

/assign @hediet

hediet commented 2 years ago

does it take up that many resources to highlight them?

The resource constraint is only one reason why this message is shown.

The other reason is that if a document uses that many invisible characters, this is probably done intentionally and it would be counter-productive to highlight every single occurence (which seems to be the case in your screenshot).

What is your use-case?

Zezombye commented 2 years ago

Finding out, in a French translation file for a game, which strings are used where (and exact matching is important). In French, "official" typography requires the use of non-breaking spaces (the bane of my existence) in some places, and the translators sometimes put them, sometimes don't.

So I wanted to find the id of the string "Equipe 1" where there is a nbsp (there are multiple matches for this string, some having a normal space, some having a nbsp), so I ctrl-f "Equipe" and look at which ones have a highlighted space, but since none of them was highlighted I thought there wasn't any nbsp, and that the file wasn't correct. In the end I had to copy paste a nbsp from internet to successfully search it, but I was confused, especially since the banner has a button to disable unicode highlighting when no highlighting is done :p

I think even if it is done intentionally, it will always be beneficial to highlight every occurrence (it's always nice to know when spaces aren't really spaces). Else, the banner should specify that no highlighting is being done at all.

hediet commented 2 years ago

Maybe a checkbox in the banner would work nicely. The checkbox would toggle a setting like "editor.unicodeHighlighting.highlightWhenBannerIsShown", which is disabled by default.

Zezombye commented 2 years ago

That would be nice yes, and also disable the banner if checked.

Also I absolutely love this feature, I no longer have to highlight some random space to find out wacky spaces :D

miguelsolorio commented 2 years ago

@hediet we should bring this banner to the ux sync as we've only reserved the banner for vscode.dev and workspace trust and already have other patterns for altering the user of errors/warnings in the editor

phinsfan0479149 commented 3 months ago

The highlight limit appears to be hard-coded at 1000 characters. Anything more than that and the banner appears. Would be nice to be able to change a default value of 1000 up or down in settings.json.