Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use an associative array?
I'd take {current: _currentDocument, previous: previousDocument}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triggerHandler gets arguments in an array and then spreads them to the callback like this:
https://github.com/zaggino/brackets-git/blob/43d62647ca8d8747f1cc649019f08bc451440fcf/src/BracketsEvents.js#L51-L56

// (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