Skip to content

Commit 3bcb122

Browse files
committed
add foldMode.closingBracketBlock
1 parent ccee8e7 commit 3bcb122

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎lib/ace/mode/folding/cstyle.js‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2010, Ajax.org B.V.
55
* All rights reserved.
6-
*
6+
*
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
99
* * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
* * Neither the name of Ajax.org B.V. nor the
1515
* names of its contributors may be used to endorse or promote products
1616
* derived from this software without specific prior written permission.
17-
*
17+
*
1818
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -42,7 +42,7 @@ oop.inherits(FoldMode, BaseFoldMode);
4242

4343
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
4444
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
45-
45+
4646
this.getFoldWidgetRange = function(session, foldStyle, row) {
4747
var line = session.getLine(row);
4848
var match = line.match(this.foldingStartMarker);
@@ -59,7 +59,7 @@ oop.inherits(FoldMode, BaseFoldMode);
5959

6060
if (foldStyle !== "markbeginend")
6161
return;
62-
62+
6363
var match = line.match(this.foldingStopMarker);
6464
if (match) {
6565
var i = match.index + match[0].length;
@@ -70,19 +70,10 @@ oop.inherits(FoldMode, BaseFoldMode);
7070
return range;
7171
}
7272

73-
var end = {row: row, column: i};
74-
var start = session.$findOpeningBracket(match[1], end);
75-
76-
if (!start)
77-
return;
78-
79-
start.column++;
80-
end.column--;
81-
82-
return Range.fromPoints(start, end);
73+
return this.closingBracketBlock(session, match[1], row, i);
8374
}
8475
};
85-
76+
8677
}).call(FoldMode.prototype);
8778

8879
});

‎lib/ace/mode/folding/fold_mode.js‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2010, Ajax.org B.V.
55
* All rights reserved.
6-
*
6+
*
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
99
* * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
* * Neither the name of Ajax.org B.V. nor the
1515
* names of its contributors may be used to endorse or promote products
1616
* derived from this software without specific prior written permission.
17-
*
17+
*
1818
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -103,6 +103,18 @@ var FoldMode = exports.FoldMode = function() {};
103103
return Range.fromPoints(start, end);
104104
};
105105

106+
this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
107+
var end = {row: row, column: column};
108+
var start = session.$findOpeningBracket(bracket, end);
109+
110+
if (!start)
111+
return;
112+
113+
start.column++;
114+
end.column--;
115+
116+
return Range.fromPoints(start, end);
117+
};
106118
}).call(FoldMode.prototype);
107119

108120
});

0 commit comments

Comments
 (0)