in lib/ace/mode/folding/ruby.js [71:114]
this.getFoldWidget = function (session, foldStyle, row) {
var line = session.getLine(row);
var isStart = this.foldingStartMarker.test(line);
var isEnd = this.foldingStopMarker.test(line);
if (isStart && !isEnd) {
var match = line.match(this.foldingStartMarker);
if (match[1]) {
if (match[1] == "if" || match[1] == "else" || match[1] == "while" || match[1] == "until" || match[1] == "unless") {
if (match[1] == "else" && /^\s*else\s*$/.test(line) === false) {
return;
}
if (/^\s*(?:if|else|while|until|unless)\s*/.test(line) === false) {
return;
}
}
if (match[1] == "when") {
if (/\sthen\s/.test(line) === true) {
return;
}
}
if (session.getTokenAt(row, match.index + 2).type === "keyword")
return "start";
} else if (match[3]) {
if (session.getTokenAt(row, match.index + 1).type === "comment.multiline")
return "start";
} else {
return "start";
}
}
if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd)
return "";
var match = line.match(this.foldingStopMarker);
if (match[3] === "end") {
if (session.getTokenAt(row, match.index + 1).type === "keyword")
return "end";
} else if (match[1]) {
if (session.getTokenAt(row, match.index + 1).type === "comment.multiline")
return "end";
} else
return "end";
};