simplify lua folding

This commit is contained in:
nightwing 2012-11-03 21:52:41 +04:00
commit 5ab20469c0

View file

@ -53,6 +53,8 @@ oop.inherits(FoldMode, BaseFoldMode);
if (isStart && !isEnd) {
var match = line.match(this.foldingStartMarker);
if (match[1] == "then" && /\belseif\b/.test(line))
return;
if (match[1]) {
if (session.getTokenAt(row, match.index + 1).type === "keyword")
return "start";
@ -113,16 +115,10 @@ oop.inherits(FoldMode, BaseFoldMode);
"do": 1,
"then": 1,
"elseif": -1,
"else": 0,
"end": -1,
"repeat": 1,
"until": -1,
};
var voidKeywords = {
"elseif": 1,
"if": 1,
"for": 1
};
var token = stream.getCurrentToken();
if (!token || token.type != "keyword")
@ -130,15 +126,7 @@ oop.inherits(FoldMode, BaseFoldMode);
var val = token.value;
var stack = [val];
var dir;
if (voidKeywords[val]) {
stack = [];
dir = 1;
} else if (val === "else") {
dir = 1;
} else {
dir = indentKeywords[val];
}
var dir = indentKeywords[val];
if (!dir)
return;
@ -156,7 +144,7 @@ oop.inherits(FoldMode, BaseFoldMode);
stack.unshift(token.value);
} else if (level <= 0) {
stack.shift();
if (!stack.length)
if (!stack.length && token.value != "elseif")
break;
if (level === 0)
stack.unshift(token.value);