Closed rksm closed 8 years ago
Regular expressions are currently not supported. I could try to come up with some rules that work 90% of the time but the parsing/reading rules for regular expressions in JavaScript are really difficult.
For example, a slash following a function declaration is always the start of a regular expression:
function f() { }
/y/g // regex
However, a slash following a function expression is a divide operator:
x =
function f() { }
/y/g // divide
Maybe the highlighting should eventually done with a real parser which would also be necessary for any structural code editing (#39).
If you can add a pragmatic solution for highlighting regexps then this will be very much appreciated! As an alternative, is there a good heuristic to contain wrong highlights? It's not a problem to have wrong highlighting for a single line but if an issue in the beginning of the file breaks highlighting for the entire rest then this isn't good.
Using the AST: I would rather not want to do this. a) It depends on how well the parser can handle errors. If a syntax error breaks highlighting then this is not OK b) frequency of highlight updates should be higher to give a good "snappy" feeling, complete parses are rather expensive, even with acorn. To not perceive a lag the update between typing and re-rendering we don't have more than 25ms max, that is for everything, from getting the key event / text change to put it into the DOM