dcortes92 / vs-freemarker

FreeMarker language colorization extension for Visual Studio Code
MIT License
25 stars 14 forks source link

Syntax highlight bug with some #if statements #9

Closed pieroxy closed 7 years ago

pieroxy commented 7 years ago

<#if (a>b) && b==2> the first > will be interpreted as the end of the #if statement.

pieroxy commented 7 years ago

I forgot to say I was infinitely grateful for this project before complaining, so there, I said it :-)

vinlos commented 7 years ago

hello @pieroxy! I confirm the issue. Since the syntax was copied by TextMate Freemarker bundle, it would be interesting to understand whether the issue is also there

dcortes92 commented 7 years ago

Hi @pieroxy thanks for submitting your issue. Yes you're right when using those characters inside the if directive you will get a syntax highlight problem. However, according to the freemarker docs you should use gt and gte in order to avoid this.

I'll leave the note that tackles this.

When you want to test if x > 0 or x >= 0, writing <#if x > 0> and <#if x >= 0> is WRONG, as the first > will close the #if tag. To work that around, write <#if x gt 0> or <#if gte 0>. Also note that if the comparison occurs inside parentheses, you will have no such problem, like <#if foo.bar(x > 0)> works as expected.

I'll close this issue for now. But I'll try to integrate a solution maybe a warning when using those characters inside the if directive. Let me know if you are able to use this approach.

Thanks,

Daniel

pieroxy commented 7 years ago

Well, the workaround works but it is less legible. And the syntax I use is perfecly legal freemarker. That said I understand your point. Thanks for taking the time.