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

Commit bd4018d

Browse files
committed
Integration test failures fixed
1 parent 967738e commit bd4018d

File tree

5 files changed

+59
-32
lines changed

5 files changed

+59
-32
lines changed

src/command/Commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ define(function (require, exports, module) {
4343
exports.FILE_SAVE_AS = "file.saveAs"; // DocumentCommandHandlers.js handleFileSaveAs()
4444
exports.FILE_CLOSE = "file.close"; // DocumentCommandHandlers.js handleFileClose()
4545
exports.FILE_CLOSE_ALL = "file.close_all"; // DocumentCommandHandlers.js handleFileCloseAll()
46+
exports.FILE_CLOSE_LIST = "file.close_list"; // DocumentCommandHandlers.js handleFileCloseList()
4647
exports.FILE_ADD_TO_WORKING_SET = "file.addToWorkingSet"; // DocumentCommandHandlers.js handleFileAddToWorkingSet()
4748
exports.FILE_LIVE_FILE_PREVIEW = "file.liveFilePreview"; // LiveDevelopment/main.js _handleGoLiveCommand()
4849
exports.FILE_LIVE_HIGHLIGHT = "file.previewHighlight"; // LiveDevelopment/main.js _handlePreviewHighlightCommand()

src/document/DocumentCommandHandlers.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,16 @@ define(function (require, exports, module) {
730730
var doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
731731
if (doc) {
732732
var savePromise = handleFileSave({doc: doc});
733-
savePromise.fail(function (error) {
734-
if (error === USER_CANCELED) {
735-
userCanceled = true;
736-
}
737-
});
733+
savePromise
734+
.done(function (newFile) {
735+
file.fullPath = newFile.fullPath;
736+
file.name = newFile.name;
737+
})
738+
.fail(function (error) {
739+
if (error === USER_CANCELED) {
740+
userCanceled = true;
741+
}
742+
});
738743
return savePromise;
739744
} else {
740745
// working set entry that was never actually opened - ignore
@@ -913,7 +918,7 @@ define(function (require, exports, module) {
913918
return promise;
914919
}
915920

916-
function _doCloseDocumentList(list, promptOnly) {
921+
function _doCloseDocumentList(list, promptOnly, clearCurrentDoc) {
917922
var result = new $.Deferred(),
918923
unsavedDocs = [];
919924

@@ -997,7 +1002,7 @@ define(function (require, exports, module) {
9971002
// guarantees that handlers run in the order they are added.
9981003
result.done(function () {
9991004
if (!promptOnly) {
1000-
DocumentManager.removeFromWorkingSet(list);
1005+
DocumentManager.removeListFromWorkingSet(list, (clearCurrentDoc || true));
10011006
}
10021007
});
10031008

@@ -1016,8 +1021,8 @@ define(function (require, exports, module) {
10161021
return _doCloseDocumentList(DocumentManager.getWorkingSet(), (commandData && commandData.promptOnly));
10171022
}
10181023

1019-
function handleFileCloseList(documentList) {
1020-
return _doCloseDocumentList(documentList);
1024+
function handleFileCloseList(commandData) {
1025+
return _doCloseDocumentList((commandData && commandData.documentList), false);
10211026
}
10221027

10231028
/**
@@ -1226,8 +1231,6 @@ define(function (require, exports, module) {
12261231

12271232
// Exported for unit testing only
12281233
exports._parseDecoratedPath = _parseDecoratedPath;
1229-
1230-
exports.handleFileCloseList = handleFileCloseList;
12311234

12321235
// Register global commands
12331236
CommandManager.register(Strings.CMD_FILE_OPEN, Commands.FILE_OPEN, handleFileOpen);
@@ -1246,6 +1249,7 @@ define(function (require, exports, module) {
12461249

12471250
CommandManager.register(Strings.CMD_FILE_CLOSE, Commands.FILE_CLOSE, handleFileClose);
12481251
CommandManager.register(Strings.CMD_FILE_CLOSE_ALL, Commands.FILE_CLOSE_ALL, handleFileCloseAll);
1252+
CommandManager.register(Strings.CMD_FILE_CLOSE_LIST, Commands.FILE_CLOSE_LIST, handleFileCloseList);
12491253

12501254
if (brackets.platform === "win") {
12511255
CommandManager.register(Strings.CMD_EXIT, Commands.FILE_QUIT, handleFileQuit);

src/document/DocumentManager.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -316,35 +316,28 @@ define(function (require, exports, module) {
316316
// Dispatch event
317317
$(exports).triggerHandler("workingSetAddList", [uniqueFileList]);
318318
}
319-
320-
function _internalRemoveFromWorkingSet(file) {
319+
320+
/**
321+
* Warning: low level API - use FILE_CLOSE command in most cases.
322+
* Removes the given file from the working set list, if it was in the list. Does not change
323+
* the current editor even if it's for this file. Does not prompt for unsaved changes.
324+
* @param {!FileEntry} file
325+
* @param {boolean=} true to suppress redraw after removal
326+
*/
327+
function removeFromWorkingSet(file, suppressRedraw) {
321328
// If doc isn't in working set, do nothing
322329
var index = findInWorkingSet(file.fullPath);
323330
if (index === -1) {
324-
return false;
331+
return;
325332
}
326333

327334
// Remove
328335
_workingSet.splice(index, 1);
329336
_workingSetMRUOrder.splice(findInWorkingSet(file.fullPath, _workingSetMRUOrder), 1);
330337
_workingSetAddedOrder.splice(findInWorkingSet(file.fullPath, _workingSetAddedOrder), 1);
331338

332-
return true;
333-
}
334-
335-
function removeFromWorkingSet(content, suppressRedraw) {
336-
if (content) {
337-
if ($.isArray(content)) {
338-
content.forEach(function (file) {
339-
_internalRemoveFromWorkingSet(file);
340-
});
341-
342-
$(exports).triggerHandler("workingSetRemoveList", [content]);
343-
344-
} else if (_internalRemoveFromWorkingSet(content)) {
345-
$(exports).triggerHandler("workingSetRemove", [content, suppressRedraw]);
346-
}
347-
}
339+
// Dispatch event
340+
$(exports).triggerHandler("workingSetRemove", [file, suppressRedraw]);
348341
}
349342

350343
/**
@@ -575,6 +568,33 @@ define(function (require, exports, module) {
575568
_clearCurrentDocument();
576569
_removeAllFromWorkingSet();
577570
}
571+
572+
function removeListFromWorkingSet(list, clearCurrentDocument) {
573+
var fileList = [], index;
574+
575+
if (!list) {
576+
return;
577+
}
578+
579+
if (clearCurrentDocument) {
580+
_clearCurrentDocument();
581+
}
582+
583+
list.forEach(function (file) {
584+
index = findInWorkingSet(file.fullPath);
585+
586+
if (index !== -1) {
587+
fileList.push(_workingSet[index]);
588+
589+
_workingSet.splice(index, 1);
590+
_workingSetMRUOrder.splice(findInWorkingSet(file.fullPath, _workingSetMRUOrder), 1);
591+
_workingSetAddedOrder.splice(findInWorkingSet(file.fullPath, _workingSetAddedOrder), 1);
592+
}
593+
});
594+
595+
$(exports).triggerHandler("workingSetRemoveList", [fileList]);
596+
}
597+
578598

579599
/**
580600
* Cleans up any loose Documents whose only ref is its own master Editor, and that Editor is not
@@ -946,6 +966,7 @@ define(function (require, exports, module) {
946966
exports.addToWorkingSet = addToWorkingSet;
947967
exports.addListToWorkingSet = addListToWorkingSet;
948968
exports.removeFromWorkingSet = removeFromWorkingSet;
969+
exports.removeListFromWorkingSet = removeListFromWorkingSet;
949970
exports.getNextPrevFile = getNextPrevFile;
950971
exports.swapWorkingSetIndexes = swapWorkingSetIndexes;
951972
exports.sortWorkingSet = sortWorkingSet;

src/extensions/default/CloseOthers/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ define(function (require, exports, module) {
5656
for (i = start; i < end; i++) {
5757
docList.push(workingSet[i]);
5858
}
59-
60-
docCH.handleFileCloseList(docList);
59+
60+
CommandManager.execute(Commands.FILE_CLOSE_LIST, {documentList: docList});
6161
}
6262

6363
if (settings.close_below) {

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ define({
209209
"CMD_OPEN_FOLDER" : "Open Folder\u2026",
210210
"CMD_FILE_CLOSE" : "Close",
211211
"CMD_FILE_CLOSE_ALL" : "Close All",
212+
"CMD_FILE_CLOSE_LIST" : "Close List",
212213
"CMD_FILE_CLOSE_OTHERS" : "Close Others",
213214
"CMD_FILE_CLOSE_ABOVE" : "Close Others Above",
214215
"CMD_FILE_CLOSE_BELOW" : "Close Others Below",

0 commit comments

Comments
 (0)