mathiasfrohlich / vscode-kotlin

Kotlin language support for VS Code
Apache License 2.0
201 stars 21 forks source link

Fix #31 - Fix "Syntax highlighting breaks after < and <= operators" #40

Closed wildlava closed 4 years ago

wildlava commented 5 years ago

The issue is that the highlighting code cannot determine if a "<" character is a "less than" operator or the start of a generic type parameter section. So, currently, when "<" is seen, all code after it is highlighted as if it were in a generic type parameter section. The code that handles this only highlights "out" and "in" keywords and includes "#types".

The fix I am proposing is to remove the generic type parameter section code and add "out" and "in" to the storage.modifier.kotlin keyword list.

If proper syntax is used in a generic type parameter section, the highlighting should be correct (but non-relevant syntax will be highlighted, too). Also, "out" and "in" will be highlighted even if outside such a section. But there are other things like this that happen with the existing code, like highlighting "protected" as a keyword even if used as a variable name, which is valid syntax.

This may be the best we can do using TextMate. It certainly is better than what happens when this issue is triggered.

wildlava commented 5 years ago

Hi, just wondering if anyone has had a chance to look at this. It looks like there has not been a lot of activity lately... I'd love to get this into the repo, esp. if it will improve things. Thanks!

nishtahir commented 5 years ago

Thanks for your contribution - I'll take a look a this

dlemstra commented 4 years ago

A workaround until this is merged is to replace the file .vscode\extensions\mathiasfrohlich.kotlin-1.7.0\syntaxes\Kotlin.tmLanguage with the file from this PR. That folder can be found in your $HOME or %USERPROFILE% folder.

wildlava commented 4 years ago

A workaround until this is merged is to replace the file .vscode\extensions\mathiasfrohlich.kotlin-1.7.0\syntaxes\Kotlin.tmLanguage with the file from this PR. That folder can be found in your $HOME or %USERPROFILE% folder.

Thanks! Yep, I did something similar when I was testing my changes. Hopefully this will get merged (or if not completely correct that an even better fix can be made).

nishtahir commented 4 years ago

Thanks for your contribution on this issue.

Mithrandir2k18 commented 4 years ago

Can you please release this fix as patch version 1.7.1? The < operator breaking synthax highlighting for the entire rest of a file seems to be a pressing enough issue to warrant a timely release.

nishtahir commented 4 years ago

cc @mathiasfrohlich ^

mathiasfrohlich commented 4 years ago

It is now Live Thanks for the contribution