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

Commit b0a363b

Browse files
swmitranethip
authored andcommitted
Handle InMemory files in recent file list (#12496)
* Handle InMemory files in recent file list * Updating tab spacing * Update main.js * Update main.js * Fix tab spacing issues
1 parent 60bcc7b commit b0a363b

File tree

1 file changed

+29
-10
lines changed
  • src/extensions/default/NavigationAndHistory

1 file changed

+29
-10
lines changed

src/extensions/default/NavigationAndHistory/main.js

+29-10
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,25 @@ define(function (require, exports, module) {
164164
var deferred = new $.Deferred(),
165165
fileEntry = FileSystem.getFileForPath(entry.file);
166166

167-
fileEntry.exists(function (err, exists) {
168-
if (!err && exists) {
169-
deferred.resolve();
170-
} else {
167+
if (entry.inMem) {
168+
var indxInWS = MainViewManager.findInWorkingSet(entry.paneId, entry.file);
169+
// Remove entry if InMemoryFile is not found in Working set
170+
if (indxInWS === -1) {
171171
_mrofList[index] = null;
172172
deferred.reject();
173+
} else {
174+
deferred.resolve();
173175
}
174-
});
176+
} else {
177+
fileEntry.exists(function (err, exists) {
178+
if (!err && exists) {
179+
deferred.resolve();
180+
} else {
181+
_mrofList[index] = null;
182+
deferred.reject();
183+
}
184+
});
185+
}
175186

176187
return deferred.promise();
177188
}
@@ -569,7 +580,9 @@ define(function (require, exports, module) {
569580
* @private
570581
* @param {Editor} editor - editor to extract file information
571582
*/
572-
function _addToMROFList(filePath, paneId, cursorPos) {
583+
function _addToMROFList(file, paneId, cursorPos) {
584+
585+
var filePath = file.fullPath;
573586

574587
if (!paneId) { // Don't handle this if not a full view/editor
575588
return;
@@ -591,6 +604,13 @@ define(function (require, exports, module) {
591604

592605
entry = _makeMROFListEntry(filePath, paneId, cursorPos);
593606

607+
// Check if the file is an InMemoryFile
608+
if (file.constructor.name === "InMemoryFile") {
609+
// Mark the entry as inMem, so that we can knock it off from the list when removed from working set
610+
entry.inMem = true;
611+
}
612+
613+
594614
if (index !== -1) {
595615
_mrofList.splice(index, 1);
596616
}
@@ -600,7 +620,6 @@ define(function (require, exports, module) {
600620

601621
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
602622
}
603-
604623

605624
// To update existing entry if a move has happened
606625
function _handleWorkingSetMove(event, file, sourcePaneId, destinationPaneId) {
@@ -755,7 +774,7 @@ define(function (require, exports, module) {
755774
_initRecentFilesList();
756775
}
757776

758-
_addToMROFList(newFile.fullPath, newPaneId);
777+
_addToMROFList(newFile, newPaneId);
759778
}
760779
}
761780

@@ -766,9 +785,9 @@ define(function (require, exports, module) {
766785
_initRecentFilesList();
767786
}
768787

769-
var filePath = current.document.file.fullPath;
788+
var file = current.document.file;
770789
var paneId = current._paneId;
771-
_addToMROFList(filePath, paneId, current.getCursorPos(true, "first"));
790+
_addToMROFList(file, paneId, current.getCursorPos(true, "first"));
772791
}
773792

774793
if (previous) { // Capture the last know cursor position

0 commit comments

Comments
 (0)