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

Commit

Permalink
Merge pull request #13269 from thehogfather/thehogfather/issue-13264-…
Browse files Browse the repository at this point in the history
…save-fold-states-error

Addresses #13264 where setting `saveFoldStates` preference to false caused folding problems
  • Loading branch information
lkcampbell authored Apr 7, 2017
2 parents 0442881 + 2d317ed commit f9afa59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/extensions/default/CodeFolding/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,19 @@ define(function (require, exports, module) {
}

var saveFolds = prefs.getSetting("saveFoldStates");

if (!editor || !saveFolds) {
if (editor) {
editor._codeMirror._lineFolds = editor._codeMirror._lineFolds || {};
}
return;
}
var viewState = ViewStateManager.getViewState(editor.document.file);
var cm = editor._codeMirror;
var viewState = ViewStateManager.getViewState(editor.document.file);
var path = editor.document.file.fullPath;
var folds = cm._lineFolds || prefs.getFolds(path) || {};

//separate out selection folds from non-selection folds
var nonSelectionFolds = {}, selectionFolds = {}, range;
Object.keys(folds).forEach(function (line) {
Expand Down
8 changes: 8 additions & 0 deletions src/extensions/default/CodeFolding/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ define(function (require, exports, module) {
var marks = getEditorFoldMarks();
expect(marks.length).toEqual(0);
});

runs(function () {
var lineNumbers = foldableLines;
var marks = getGutterFoldMarks();
var gutterNumbers = marks.filter(filterOpen)
.map(getLineNumber);
expect(gutterNumbers).toEqual(toZeroIndex(lineNumbers));
});
});

it("can set the minimum fold size", function () {
Expand Down

0 comments on commit f9afa59

Please sign in to comment.