JetBrains / JetBrainsMono

JetBrains Mono – the free and open-source typeface for developers
https://jetbrains.com/mono
SIL Open Font License 1.1
10.6k stars 299 forks source link

Problem about the <- exclusion #403

Open yvvt0379 opened 3 years ago

yvvt0379 commented 3 years ago

<-1> looks right, but <-12> still looks wrong. Screenshot_20210129_174428

auduchinok commented 3 years ago

It may be difficult to find the right balance here.

In the following assignment examples I'd expect the <- ligature to be applied (though, I'd also expect a space after it in a properly formatted code):

a<-1
a<-123
a<-b

a<-b>2
a<-1>b

If adding more exclusions, the following cases should probably also be taken into account:

// <-identifier>
// <-identifier_with_undersores>
// <-identifier-2>

The current rules work as expected when text is split into tokens and each token is highlighted differently. The problem on the screenshot above is due to comment it not being split into parts in the same way as code. There's a chance that disabling ligature completely in such cases might make more harm than good in the actual code (i.e. not comments and string literals parts).

Update: at the same time the splitting text into tokens helps it work as expected even in the <-1> case, so more exclusions seems not that bad:

Screenshot 2021-01-29 at 13 02 04
philippnurullin commented 3 years ago

Added an exclusion up the 3 digits.

@auduchinok I'm not getting the "identifeier" thing. What exact symbols can be used it that expression?

auduchinok commented 3 years ago

@philippnurullin It mostly was about comments, i.e. some random texts that are ignored by programming languages and that could be, for instance, a description of the code nearby or a piece of code that is kind of removed by placing it into a comment (done by adding // before commented text in many programming languages).

AFAIK IntelliJ applies ligatures to differently highlighted pieces of code, so a ligature should fit into a highlighted piece of code, and in the case of a comment the whole comment is usually highlighted as one big thing.

What I was trying to say is there could be legitimate cases where <- ligature could be desired and there are cases where - and some other text are used inside angle brackets, and there's probably no way to distinguish these cases in a comment (because a comment is just a random text in most cases). These exclusions likely won't help much with text in comments. I can write // <-1234> or // <-1e123> and it already might't work with 3 digits exclusion in a way I could expect it to.

The initial report is about using text in a comment, that's why I'm thinking about comments a lot here. If this wasn't in a comment, the text would likely be split in a way that <- ligature wouldn't be applied by the platform even without the exclusion.