fix #510 #{} highlighting for CoffeeScript

This commit is contained in:
nightwing 2013-04-06 15:00:06 +04:00
commit f40cc1c31d
2 changed files with 63 additions and 10 deletions

View file

@ -100,10 +100,12 @@
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["paren.lparen","({"], ["paren.lparen","("],
["paren","{"],
["keyword.operator","/"], ["keyword.operator","/"],
["identifier","abc"], ["identifier","abc"],
["paren.rparen","})"], ["paren","}"],
["paren.rparen",")"],
["text"," "], ["text"," "],
["storage.type","=>"] ["storage.type","=>"]
],[ ],[
@ -113,10 +115,12 @@
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["paren.lparen","({"], ["paren.lparen","("],
["paren","{"],
["identifier","abc"], ["identifier","abc"],
["keyword.operator","/"], ["keyword.operator","/"],
["paren.rparen","})"], ["paren","}"],
["paren.rparen",")"],
["text"," "], ["text"," "],
["storage.type","->"] ["storage.type","->"]
],[ ],[
@ -150,10 +154,12 @@
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["paren.lparen","({"], ["paren.lparen","("],
["paren","{"],
["paren.rparen",")"], ["paren.rparen",")"],
["identifier","abc"], ["identifier","abc"],
["paren.rparen","})"], ["paren","}"],
["paren.rparen",")"],
["text"," "], ["text"," "],
["storage.type","->"] ["storage.type","->"]
],[ ],[
@ -163,9 +169,12 @@
["text"," "], ["text"," "],
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["paren.lparen","({"], ["paren.lparen","("],
["paren","{"],
["identifier","abc"], ["identifier","abc"],
["paren.rparen",")})"], ["paren.rparen",")"],
["paren","}"],
["paren.rparen",")"],
["text"," "], ["text"," "],
["storage.type","->"] ["storage.type","->"]
],[ ],[
@ -427,9 +436,36 @@
["keyword.operator","="], ["keyword.operator","="],
["text"," "], ["text"," "],
["string.start","\""], ["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","\""], ["string.end","\""],
["comment","#{a + b}\"} + 2}\""] ["paren","}"],
["text"," "],
["keyword.operator","+"],
["text"," "],
["constant.numeric","2"],
["paren.string","}"],
["string.end","\""]
],[ ],[
"qqdoc", "qqdoc",
["string","\"\"\"heredoc"] ["string","\"\"\"heredoc"]

View file

@ -107,6 +107,7 @@ define(function(require, exports, module) {
regex : '"""', regex : '"""',
next : [ next : [
{token : "string", regex : '"""', next : "start"}, {token : "string", regex : '"""', next : "start"},
{token : "paren.string", regex : '#{', push : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"} {defaultToken: "string"}
] ]
@ -121,6 +122,7 @@ define(function(require, exports, module) {
stateName: "qqstring", stateName: "qqstring",
token : "string.start", regex : '"', next : [ token : "string.start", regex : '"', next : [
{token : "string.end", regex : '"', next : "start"}, {token : "string.end", regex : '"', next : "start"},
{token : "paren.string", regex : '#{', push : "start"},
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"} {defaultToken: "string"}
] ]
@ -131,6 +133,21 @@ define(function(require, exports, module) {
{token : "constant.language.escape", regex : stringEscape}, {token : "constant.language.escape", regex : stringEscape},
{defaultToken: "string"} {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", token : "string.regex",
regex : "///", regex : "///",