Skip to content
Snippets Groups Projects
Commit 34d8dc43 authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[smarty mode] Prevent outer mode from getting confused by Smarty tags

Issue #3186
parent 40b5625b
No related branches found
No related tags found
No related merge requests found
......@@ -47,10 +47,17 @@
}
function tokenTop(stream, state) {
if (stream.match(leftDelimiter, true)) {
var string = stream.string;
for (var scan = stream.pos;;) {
var nextMatch = string.indexOf(leftDelimiter, scan);
scan = nextMatch + leftDelimiter.length;
if (nextMatch == -1 || !doesNotCount(stream, nextMatch + leftDelimiter.length)) break;
}
if (nextMatch == stream.pos) {
stream.match(leftDelimiter);
if (stream.eat("*")) {
return chain(stream, state, tokenBlock("comment", "*" + rightDelimiter));
} else if (!doesNotCount(stream)) {
} else {
state.depth++;
state.tokenize = tokenSmarty;
last = "startTag";
......@@ -58,11 +65,9 @@
}
}
if (nextMatch > -1) stream.string = string.slice(0, nextMatch);
var token = baseMode.token(stream, state.base);
var text = stream.current();
var found = text.indexOf(leftDelimiter);
if (found > -1 && !doesNotCount(stream, stream.start + found + 1))
stream.backUp(text.length - found);
if (nextMatch > -1) stream.string = string;
return token;
}
......@@ -205,6 +210,12 @@
state.last = last;
return style;
},
indent: function(state, text) {
if (state.tokenize == tokenTop && baseMode.indent)
return baseMode.indent(state.base, text);
else
return CodeMirror.Pass;
},
blockCommentStart: leftDelimiter + "*",
blockCommentEnd: "*" + rightDelimiter
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment