Permalink
Browse files

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 b0a363b71822e16936f5cac4ddc93066e620853f @swmitra swmitra committed with nethip Jun 8, 2016
Showing with 29 additions and 10 deletions.
  1. +29 −10 src/extensions/default/NavigationAndHistory/main.js
@@ -164,14 +164,25 @@ define(function (require, exports, module) {
var deferred = new $.Deferred(),
fileEntry = FileSystem.getFileForPath(entry.file);
- fileEntry.exists(function (err, exists) {
- if (!err && exists) {
- deferred.resolve();
- } else {
+ if (entry.inMem) {
+ var indxInWS = MainViewManager.findInWorkingSet(entry.paneId, entry.file);
+ // Remove entry if InMemoryFile is not found in Working set
+ if (indxInWS === -1) {
_mrofList[index] = null;
deferred.reject();
+ } else {
+ deferred.resolve();
}
- });
+ } else {
+ fileEntry.exists(function (err, exists) {
+ if (!err && exists) {
+ deferred.resolve();
+ } else {
+ _mrofList[index] = null;
+ deferred.reject();
+ }
+ });
+ }
return deferred.promise();
}
@@ -569,7 +580,9 @@ define(function (require, exports, module) {
* @private
* @param {Editor} editor - editor to extract file information
*/
- function _addToMROFList(filePath, paneId, cursorPos) {
+ function _addToMROFList(file, paneId, cursorPos) {
+
+ var filePath = file.fullPath;
if (!paneId) { // Don't handle this if not a full view/editor
return;
@@ -591,6 +604,13 @@ define(function (require, exports, module) {
entry = _makeMROFListEntry(filePath, paneId, cursorPos);
+ // Check if the file is an InMemoryFile
+ if (file.constructor.name === "InMemoryFile") {
+ // Mark the entry as inMem, so that we can knock it off from the list when removed from working set
+ entry.inMem = true;
+ }
+
+
if (index !== -1) {
_mrofList.splice(index, 1);
}
@@ -600,7 +620,6 @@ define(function (require, exports, module) {
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
}
-
// To update existing entry if a move has happened
function _handleWorkingSetMove(event, file, sourcePaneId, destinationPaneId) {
@@ -755,7 +774,7 @@ define(function (require, exports, module) {
_initRecentFilesList();
}
- _addToMROFList(newFile.fullPath, newPaneId);
+ _addToMROFList(newFile, newPaneId);
}
}
@@ -766,9 +785,9 @@ define(function (require, exports, module) {
_initRecentFilesList();
}
- var filePath = current.document.file.fullPath;
+ var file = current.document.file;
var paneId = current._paneId;
- _addToMROFList(filePath, paneId, current.getCursorPos(true, "first"));
+ _addToMROFList(file, paneId, current.getCursorPos(true, "first"));
}
if (previous) { // Capture the last know cursor position

0 comments on commit b0a363b

Please sign in to comment.