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

Makes the content of script and style tags collapsible #13198

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/extensions/default/CodeFolding/foldhelpers/foldcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ define(function (require, exports, module) {
keys.forEach(function (lineNumber) {
lineNumber = +lineNumber;
if (lineNumber >= cm.firstLine() && lineNumber <= cm.lastLine()) {
range = rf(cm, CodeMirror.Pos(lineNumber));
range = rf(cm, CodeMirror.Pos(lineNumber, 0));
cachedRange = folds[lineNumber];
if (range && cachedRange && range.from.line === cachedRange.from.line &&
range.to.line === cachedRange.to.line) {
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/default/CodeFolding/foldhelpers/foldgutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define(function (require, exports, module) {
var sr = _isCurrentlyFolded(i), // surrounding range for the current line if one exists
range;
var mark = marker("CodeMirror-foldgutter-blank");
var pos = CodeMirror.Pos(i),
var pos = CodeMirror.Pos(i, 0),
func = opts.rangeFinder || CodeMirror.fold.auto;
// don't look inside collapsed ranges
if (sr) {
Expand Down Expand Up @@ -147,7 +147,7 @@ define(function (require, exports, module) {
* @returns {TextMarker} A CodeMirror TextMarker object
*/
function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line);
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
Expand Down Expand Up @@ -220,7 +220,7 @@ define(function (require, exports, module) {

if (linesDiff === 0) {
if (foldedLines.indexOf(from) >= 0) {
newRange = rf(cm, CodeMirror.Pos(from));
newRange = rf(cm, CodeMirror.Pos(from, 0));
if (newRange && newRange.to.line - newRange.from.line >= minFoldSize) {
cm._lineFolds[from] = newRange;
} else {
Expand Down
16 changes: 13 additions & 3 deletions src/extensions/default/CodeFolding/unittest-files/test.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<html>
<head>

<style>
.test {
/* this should be collapsible */
}
</style>
<script>
function () {
/* this should be collapsible */
}
</script>
</head>
<body>

<form action="#" method="post">
<div>
<label for="name">Text Input:</label>
Expand All @@ -12,7 +20,9 @@
<table>
<thead>
<tr>
<th></th>
<th>
{{handlebars}}
</th>
</tr>
</thead>
<tbody>
Expand Down
10 changes: 5 additions & 5 deletions src/extensions/default/CodeFolding/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ define(function (require, exports, module) {
},
html: {
filePath: testDocumentDirectory + "test.html",
foldableLines: [1, 2, 5, 7, 8, 12, 13, 14, 18, 19, 24, 27],
sameLevelFoldableLines: [8, 24],
firstSelection: {start: {line: 3, ch: 0}, end: {line: 10, ch: 0}},
secondSelection: {start: {line: 6, ch: 0}, end: {line: 17, ch: 4}}
foldableLines: [1, 2, 3, 4, 8, 9, 14, 15, 16, 20, 21, 22, 23, 28, 29, 34, 37],
sameLevelFoldableLines: [3, 8],
firstSelection: {start: {line: 38, ch: 0}, end: {line: 41, ch: 0}},
secondSelection: {start: {line: 42, ch: 0}, end: {line: 45, ch: 4}}
},
hbs: {
filePath: testDocumentDirectory + "test.hbs",
Expand Down Expand Up @@ -382,7 +382,7 @@ define(function (require, exports, module) {
});
});

it("can be disable persistence of fold states", function () {
it("can disable persistence of fold states", function () {
setPreference("saveFoldStates", false);
runs(function () {
foldCodeOnLine(foldableLines[0]);
Expand Down