do not loose currentState if tokenizer uses combination of next and push
This commit is contained in:
parent
93d2b75b4f
commit
d87ba89c49
2 changed files with 19 additions and 3 deletions
|
|
@ -188,11 +188,13 @@ var RubyHighlightRules = function() {
|
||||||
rules: {
|
rules: {
|
||||||
heredoc: [{
|
heredoc: [{
|
||||||
onMatch: function(value, currentState, stack) {
|
onMatch: function(value, currentState, stack) {
|
||||||
if (value == stack[1]) {
|
if (value === stack[1]) {
|
||||||
stack.shift();
|
stack.shift();
|
||||||
stack.shift();
|
stack.shift();
|
||||||
|
this.next = stack[0] || "start";
|
||||||
return "support.class";
|
return "support.class";
|
||||||
}
|
}
|
||||||
|
this.next = "";
|
||||||
return "string";
|
return "string";
|
||||||
},
|
},
|
||||||
regex: ".*$",
|
regex: ".*$",
|
||||||
|
|
@ -203,17 +205,27 @@ var RubyHighlightRules = function() {
|
||||||
regex: "^ +"
|
regex: "^ +"
|
||||||
}, {
|
}, {
|
||||||
onMatch: function(value, currentState, stack) {
|
onMatch: function(value, currentState, stack) {
|
||||||
if (value == stack[1]) {
|
if (value === stack[1]) {
|
||||||
stack.shift();
|
stack.shift();
|
||||||
stack.shift();
|
stack.shift();
|
||||||
|
this.next = stack[0] || "start";
|
||||||
return "support.class";
|
return "support.class";
|
||||||
}
|
}
|
||||||
|
this.next = "";
|
||||||
return "string";
|
return "string";
|
||||||
},
|
},
|
||||||
regex: ".*$",
|
regex: ".*$",
|
||||||
next: "start"
|
next: "start"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
regex : "$",
|
||||||
|
token : "empty",
|
||||||
|
next : function(currentState, stack) {
|
||||||
|
if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
|
||||||
|
return stack[0];
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator",
|
token : "keyword.operator",
|
||||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,11 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
if (token.type)
|
if (token.type)
|
||||||
tokens.push(token);
|
tokens.push(token);
|
||||||
|
|
||||||
|
if (stack.length > 1) {
|
||||||
|
if (stack[0] !== currentState)
|
||||||
|
stack.unshift(currentState);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tokens : tokens,
|
tokens : tokens,
|
||||||
state : stack.length ? stack : currentState
|
state : stack.length ? stack : currentState
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue