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

Commit

Permalink
Merge pull request #7509 from adobe/zaggino/currentDocumentChange
Browse files Browse the repository at this point in the history
Add current and previous document args to currentDocumentChange event
  • Loading branch information
peterflynn committed Apr 28, 2014
2 parents 5aea3d7 + de11a49 commit 3aea013
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
* - documentRefreshed -- When a Document's contents have been reloaded from disk. The 2nd arg to the
* listener is the Document that has been refreshed.
*
* - currentDocumentChange -- When the value of getCurrentDocument() changes.
* - currentDocumentChange -- When the value of getCurrentDocument() changes. 2nd argument to the listener
* is the current document and 3rd argument is the previous document.
*
* To listen for working set changes, you must listen to *all* of these events:
* - workingSetAdd -- When a file is added to the working set (see getWorkingSet()). The 2nd arg
Expand Down Expand Up @@ -488,8 +489,9 @@ define(function (require, exports, module) {
}

// Make it the current document
var previousDocument = _currentDocument;
_currentDocument = doc;
$(exports).triggerHandler("currentDocumentChange");
$(exports).triggerHandler("currentDocumentChange", [_currentDocument, previousDocument]);
// (this event triggers EditorManager to actually switch editors in the UI)

PerfUtils.addMeasurement(perfTimerName);
Expand All @@ -503,9 +505,10 @@ define(function (require, exports, module) {
return;
} else {
// Change model & dispatch event
var previousDocument = _currentDocument;
_currentDocument = null;
// (this event triggers EditorManager to actually clear the editor UI)
$(exports).triggerHandler("currentDocumentChange");
$(exports).triggerHandler("currentDocumentChange", [_currentDocument, previousDocument]);
}
}

Expand Down

0 comments on commit 3aea013

Please sign in to comment.