diff --git a/lib/ace/mode/coffee.js b/lib/ace/mode/coffee.js index 98e862b8..34c1a55a 100644 --- a/lib/ace/mode/coffee.js +++ b/lib/ace/mode/coffee.js @@ -49,7 +49,28 @@ oop.inherits(Mode, TextMode); (function() { - var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/; + /*: + [({[=:] # Opening parentheses or brackets + |[-=]> # OR single or double arrow + |\b(?: # OR one of these words: + else # else + |try # OR try + |(?:swi|ca)tch # OR catch, optionally followed by: + (?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable + |finally # OR finally + ))\s*$ # all as the last thing on a line (allowing trailing space) + | # ---- OR ---- : + ^\s* # a line starting with optional space + (else\b\s*)? # followed by an optional "else" + (?: # followed by one of the following: + if # if + |for # OR for + |while # OR while + |loop # OR loop + )\b # (as a word) + (?!.*\bthen\b) # ... but NOT followed by "then" on the line + */ + var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/; var commentLine = /^(\s*)#/; var hereComment = /^\s*###(?!#)/; var indentation = /^\s*/;