From 27b1b49566301296899f0e76effd5424dfd221db Mon Sep 17 00:00:00 2001 From: Randy Edmunds Date: Mon, 9 Jul 2012 17:23:40 -0700 Subject: [PATCH] code review changes --- src/document/ChangedDocumentTracker.js | 11 +++++------ src/document/DocumentManager.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/document/ChangedDocumentTracker.js b/src/document/ChangedDocumentTracker.js index a2ec3080296..ba014cb1782 100644 --- a/src/document/ChangedDocumentTracker.js +++ b/src/document/ChangedDocumentTracker.js @@ -54,15 +54,14 @@ define(function (require, exports, module) { $(DocumentManager).on("afterDocumentCreate", function (event, doc) { // Only track documents in the current project if (ProjectManager.isWithinProject(doc.file.fullPath)) { - self._addListener(doc); + self._addListener(doc); } }); $(DocumentManager).on("beforeDocumentDelete", function (event, doc) { - // Only documents in the current project are tracked - if (ProjectManager.isWithinProject(doc.file.fullPath)) { - self._removeListener(doc); - } + // In case a document somehow remains loaded after its project + // has been closed, unconditionally attempt to remove the listener. + self._removeListener(doc); }); $(window).focus(this._onWindowFocus); @@ -80,7 +79,7 @@ define(function (require, exports, module) { * @private */ ChangedDocumentTracker.prototype._removeListener = function (doc) { - $(doc).off("change", self._onChange); + $(doc).off("change", this._onChange); }; /** diff --git a/src/document/DocumentManager.js b/src/document/DocumentManager.js index 9a0224caec2..36bb372efa7 100644 --- a/src/document/DocumentManager.js +++ b/src/document/DocumentManager.js @@ -1014,7 +1014,7 @@ define(function (require, exports, module) { // Initialize the active editor if (!activeFile && _workingSet.length > 0) { - activeFile = _workingSet[0]; + activeFile = _workingSet[0].fullPath; } if (activeFile) {