github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.37k stars 4.29k forks source link

Inconsistent syntax highlighting #3031

Closed BaerMitUmlaut closed 8 years ago

BaerMitUmlaut commented 8 years ago

Not sure if this the correct repository to create the issue at, but we noticed some inconsistent SQF syntax highlighting today over @acemod.

For example, compare the thens in this file: https://github.com/alganthe/Co-ops/blob/dev_altis/functions/vehicle_handler/fn_vehiclePFH.sqf In all lines but line 53, the then is black while it should be red. You can notice the same behavior in the example file of the original PR that added SQF support.

pchaigno commented 8 years ago

Linguist only selects the grammar to use for highlighting. For SQF, GitHub uses JonBons/Sublime-SQF-Language. You should open an issue there if there isn't already one.

BaerMitUmlaut commented 8 years ago

Thank you for the quick response. I assume this file is used? https://github.com/JonBons/Sublime-SQF-Language/blob/master/SQF.tmLanguage From what I can see it just contains a list of keywords, so I'm not sure how sometimes the highlighting works, and sometimes it doesn't. This package also seems to work perfectly fine in Sublime Text:

highlighting-sqf

BaerMitUmlaut commented 8 years ago

I've managed to trigger it on purpose:

// broken
if (true) then {
    [] call fncDummy
} else {
    [] call fncDummy
};

// working
if (true
) then {
    [] call fncDummy
} else {};

// broken twice
if (true) then {} else {};

It looks like it only recognizes one keyword per line:

true
false
not true
not false
true and false
true && false
Alhadis commented 8 years ago

Already spotted one mistake in the grammar:

invoke|nil|not|or|pi|preprocessFile|private|private1|private2|private3|private4|private5|private6|private7|private8|private9|spawn|step|switch|then|this|throw|to|true|try|while|with|)\b</string>

Right at the very end, there:

with|)\b</string>

The stray | is saying "Yeah, apply this rule anyway, even if nothing matches".

Alhadis commented 8 years ago

Okay, never mind. I spoke too soon: if I test my fix in Lightshow, the bug occurs. If I use the original grammar, nothing happens.

The hell.

arfon commented 8 years ago

Linguist only selects the grammar to use for highlighting. For SQF, GitHub uses JonBons/Sublime-SQF-Language. You should open an issue there if there isn't already one ;)

Closing this as it's an upstream issue (and not one that can be fixed in Linguist). @BaerMitUmlaut - please file an issue on the grammar repository and we'll pick up the fix automatically when it gets made upstream.