diff --git a/lib/ace/mode/_test/tokens_coffee.json b/lib/ace/mode/_test/tokens_coffee.json index e0e745fe..9c3967e4 100644 --- a/lib/ace/mode/_test/tokens_coffee.json +++ b/lib/ace/mode/_test/tokens_coffee.json @@ -100,10 +100,12 @@ ["text"," "], ["keyword.operator","="], ["text"," "], - ["paren.lparen","({"], + ["paren.lparen","("], + ["paren","{"], ["keyword.operator","/"], ["identifier","abc"], - ["paren.rparen","})"], + ["paren","}"], + ["paren.rparen",")"], ["text"," "], ["storage.type","=>"] ],[ @@ -113,10 +115,12 @@ ["text"," "], ["keyword.operator","="], ["text"," "], - ["paren.lparen","({"], + ["paren.lparen","("], + ["paren","{"], ["identifier","abc"], ["keyword.operator","/"], - ["paren.rparen","})"], + ["paren","}"], + ["paren.rparen",")"], ["text"," "], ["storage.type","->"] ],[ @@ -150,10 +154,12 @@ ["text"," "], ["keyword.operator","="], ["text"," "], - ["paren.lparen","({"], + ["paren.lparen","("], + ["paren","{"], ["paren.rparen",")"], ["identifier","abc"], - ["paren.rparen","})"], + ["paren","}"], + ["paren.rparen",")"], ["text"," "], ["storage.type","->"] ],[ @@ -163,9 +169,12 @@ ["text"," "], ["keyword.operator","="], ["text"," "], - ["paren.lparen","({"], + ["paren.lparen","("], + ["paren","{"], ["identifier","abc"], - ["paren.rparen",")})"], + ["paren.rparen",")"], + ["paren","}"], + ["paren.rparen",")"], ["text"," "], ["storage.type","->"] ],[ @@ -427,9 +436,36 @@ ["keyword.operator","="], ["text"," "], ["string.start","\""], - ["string","#{ 22 / 7 + {x: "], + ["paren.string","#{"], + ["text"," "], + ["constant.numeric","22"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["constant.numeric","7"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren","{"], + ["identifier","x"], + ["keyword.operator",":"], + ["text"," "], + ["string.start","\""], + ["paren.string","#{"], + ["identifier","a"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["identifier","b"], + ["paren.string","}"], ["string.end","\""], - ["comment","#{a + b}\"} + 2}\""] + ["paren","}"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["paren.string","}"], + ["string.end","\""] ],[ "qqdoc", ["string","\"\"\"heredoc"] diff --git a/lib/ace/mode/coffee_highlight_rules.js b/lib/ace/mode/coffee_highlight_rules.js index 11bbbb53..c050f78a 100644 --- a/lib/ace/mode/coffee_highlight_rules.js +++ b/lib/ace/mode/coffee_highlight_rules.js @@ -107,6 +107,7 @@ define(function(require, exports, module) { regex : '"""', next : [ {token : "string", regex : '"""', next : "start"}, + {token : "paren.string", regex : '#{', push : "start"}, {token : "constant.language.escape", regex : stringEscape}, {defaultToken: "string"} ] @@ -121,6 +122,7 @@ define(function(require, exports, module) { stateName: "qqstring", token : "string.start", regex : '"', next : [ {token : "string.end", regex : '"', next : "start"}, + {token : "paren.string", regex : '#{', push : "start"}, {token : "constant.language.escape", regex : stringEscape}, {defaultToken: "string"} ] @@ -131,6 +133,21 @@ define(function(require, exports, module) { {token : "constant.language.escape", regex : stringEscape}, {defaultToken: "string"} ] + }, { + regex: "[{}]", onMatch: function(val, state, stack) { + this.next = ""; + if (val == "{" && stack.length) { + stack.unshift("start", state); + return "paren"; + } + if (val == "}" && stack.length) { + stack.shift(); + this.next = stack.shift(); + if (this.next.indexOf("string") != -1) + return "paren.string"; + } + return "paren"; + } }, { token : "string.regex", regex : "///",