lua folding: do not show foldwidgets for keywords in comments
This commit is contained in:
parent
98b0026207
commit
704eae50c1
1 changed files with 36 additions and 3 deletions
|
|
@ -41,9 +41,42 @@ oop.inherits(FoldMode, BaseFoldMode);
|
|||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /\b(function|local\s+function|then|do|repeat)\b|{[ \t]*$|\[\[/;
|
||||
this.foldingStopMarker = /\bend\b|^\s*}|\]\]/;
|
||||
|
||||
this.foldingStartMarker = /\b(function|then|do|repeat)\b|{\s*$|(\[=*\[)/;
|
||||
this.foldingStopMarker = /\bend\b|^\s*}|\]=*\]/;
|
||||
|
||||
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 (session.getTokenAt(row, match.index + 1).type == "keyword")
|
||||
return "start";
|
||||
} else if (match[2]) {
|
||||
var type = session.getTokenAt(row + 1, 0).type
|
||||
if (type == "comment" || type == "string")
|
||||
return "start";
|
||||
} else {
|
||||
return "start";
|
||||
}
|
||||
}
|
||||
if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd)
|
||||
return "";
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match[0] == "end") {
|
||||
if (session.getTokenAt(row, match.index + 1).type == "keyword")
|
||||
return "end";
|
||||
} else if (match[0][0] == "]") {
|
||||
var type = session.getTokenAt(row - 1, 0).type
|
||||
if (type == "comment" || type == "string")
|
||||
return "end";
|
||||
} else
|
||||
return "end";
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var lines = session.doc.getAllLines(row);
|
||||
var line = lines[row];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue