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

Commit 3603849

Browse files
committed
removed unit test files
1 parent f1e4472 commit 3603849

3 files changed

Lines changed: 24 additions & 377 deletions

File tree

src/extensions/default/CodeFolding/main.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,33 @@ define(function (require, exports, module) {
8686
* @param {Editor} editor the editor whose saved line folds should be restored
8787
*/
8888
function restoreLineFolds(editor) {
89-
function isInViewStateSelection(range, selection) {
89+
/**
90+
* Checks if the range from and to Pos is the same as the selection start and end Pos
91+
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects
92+
* @param {Object} selection {start, end} where start and end are CodeMirror.Pos objects
93+
* @returns {Boolean} true if the range and selection span the same region and false otherwise
94+
*/
95+
function rangeEqualsSelection(range, selection) {
9096
return range.from.line === selection.start.line && range.from.ch === selection.start.ch &&
9197
range.to.line === selection.end.line && range.to.ch === selection.end.ch;
9298
}
9399

100+
/**
101+
* Checks if the range is equal to one of the selections in the viewState
102+
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects.
103+
* @param {Object} viewState The current editor's ViewState object
104+
* @returns {Boolean} true if the range is found in the list of selections or false if not.
105+
*/
106+
function isInViewStateSelection(range, viewState) {
107+
if (!viewState || !viewState.selections) {
108+
return false;
109+
}
110+
111+
return viewState.selections.some(function (selection) {
112+
return rangeEqualsSelection(range, selection);
113+
});
114+
}
115+
94116
var saveFolds = prefs.getSetting("saveFoldStates");
95117
if (!editor || !saveFolds) {
96118
return;
@@ -103,9 +125,7 @@ define(function (require, exports, module) {
103125
var nonSelectionFolds = {}, selectionFolds = {}, range;
104126
Object.keys(folds).forEach(function (line) {
105127
range = folds[line];
106-
if (viewState.selections && viewState.selections.some(function (selection) {
107-
return isInViewStateSelection(range, selection);
108-
})) {
128+
if (isInViewStateSelection(range, viewState)) {
109129
selectionFolds[line] = range;
110130
} else {
111131
nonSelectionFolds[line] = range;

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

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)