Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 7cdca9e

Browse files
authored
Merge pull request #13198 from thehogfather/thehogfather/issue-13165-hide-information-inside-tags
Makes the content of script and style tags collapsible
2 parents 49640bd + 6ed4e91 commit 7cdca9e

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

src/extensions/default/CodeFolding/foldhelpers/foldcode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ define(function (require, exports, module) {
139139
keys.forEach(function (lineNumber) {
140140
lineNumber = +lineNumber;
141141
if (lineNumber >= cm.firstLine() && lineNumber <= cm.lastLine()) {
142-
range = rf(cm, CodeMirror.Pos(lineNumber));
142+
range = rf(cm, CodeMirror.Pos(lineNumber, 0));
143143
cachedRange = folds[lineNumber];
144144
if (range && cachedRange && range.from.line === cachedRange.from.line &&
145145
range.to.line === cachedRange.to.line) {

src/extensions/default/CodeFolding/foldhelpers/foldgutter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ define(function (require, exports, module) {
9292
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
9393
range;
9494
var mark = marker("CodeMirror-foldgutter-blank");
95-
var pos = CodeMirror.Pos(i),
95+
var pos = CodeMirror.Pos(i, 0),
9696
func = opts.rangeFinder || CodeMirror.fold.auto;
9797
// don't look inside collapsed ranges
9898
if (sr) {
@@ -147,7 +147,7 @@ define(function (require, exports, module) {
147147
* @returns {TextMarker} A CodeMirror TextMarker object
148148
*/
149149
function getFoldOnLine(cm, line) {
150-
var pos = CodeMirror.Pos(line);
150+
var pos = CodeMirror.Pos(line, 0);
151151
var folds = cm.findMarksAt(pos) || [];
152152
folds = folds.filter(isFold);
153153
return folds.length ? folds[0] : undefined;
@@ -220,7 +220,7 @@ define(function (require, exports, module) {
220220

221221
if (linesDiff === 0) {
222222
if (foldedLines.indexOf(from) >= 0) {
223-
newRange = rf(cm, CodeMirror.Pos(from));
223+
newRange = rf(cm, CodeMirror.Pos(from, 0));
224224
if (newRange && newRange.to.line - newRange.from.line >= minFoldSize) {
225225
cm._lineFolds[from] = newRange;
226226
} else {

src/extensions/default/CodeFolding/unittest-files/test.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<html>
22
<head>
3-
3+
<style>
4+
.test {
5+
/* this should be collapsible */
6+
}
7+
</style>
8+
<script>
9+
function () {
10+
/* this should be collapsible */
11+
}
12+
</script>
413
</head>
514
<body>
6-
715
<form action="#" method="post">
816
<div>
917
<label for="name">Text Input:</label>
@@ -12,7 +20,9 @@
1220
<table>
1321
<thead>
1422
<tr>
15-
<th></th>
23+
<th>
24+
{{handlebars}}
25+
</th>
1626
</tr>
1727
</thead>
1828
<tbody>

src/extensions/default/CodeFolding/unittests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ define(function (require, exports, module) {
3737
},
3838
html: {
3939
filePath: testDocumentDirectory + "test.html",
40-
foldableLines: [1, 2, 5, 7, 8, 12, 13, 14, 18, 19, 24, 27],
41-
sameLevelFoldableLines: [8, 24],
42-
firstSelection: {start: {line: 3, ch: 0}, end: {line: 10, ch: 0}},
43-
secondSelection: {start: {line: 6, ch: 0}, end: {line: 17, ch: 4}}
40+
foldableLines: [1, 2, 3, 4, 8, 9, 14, 15, 16, 20, 21, 22, 23, 28, 29, 34, 37],
41+
sameLevelFoldableLines: [3, 8],
42+
firstSelection: {start: {line: 38, ch: 0}, end: {line: 41, ch: 0}},
43+
secondSelection: {start: {line: 42, ch: 0}, end: {line: 45, ch: 4}}
4444
},
4545
hbs: {
4646
filePath: testDocumentDirectory + "test.hbs",
@@ -382,7 +382,7 @@ define(function (require, exports, module) {
382382
});
383383
});
384384

385-
it("can be disable persistence of fold states", function () {
385+
it("can disable persistence of fold states", function () {
386386
setPreference("saveFoldStates", false);
387387
runs(function () {
388388
foldCodeOnLine(foldableLines[0]);

0 commit comments

Comments
 (0)