0

incorrect parsing of UTF-8 Javascript variable names

Leonard Hecker 12 years ago updated 12 years ago 1
Sublime Text's rules are incorrect and don't work with UTF-8 characters. For instance the rule:
([a-zA-Z_?$][\w?$]*)\s*(=)\s*(function)\s*(\()(.*?)(\))
which should "match stuff like: play = function() { … }".
But Javascript allows much more valid characters - see: http://stackoverflow.com/a/9337047

A rule like
([^\s\d]\S*)\s*(=)\s*(function)\s*(\()(.*?)(\))
is also incorrect, but works much better than the current one.

If I replace those 3
([a-zA-Z_?.$][\w?.$]*)
([a-zA-Z_?$][\w?$]*)
([a-zA-Z_$]\w*)
in JavaScript/JavaScript.tmLanguage with
([^\s\d]\S*)
it works again.

The new rule doesn't work with square brackets.

([^\s\d'"\[\]][^\s\[\]]*)

should fix this: http://dl.dropbox.com/u/39569787/JavaScript.tmLanguage