Always invoke callback with current active text editor

This makes observeActiveTextEditor consistent with observers like
observeActivePaneItem, which always invoke the callback with the current
value, regardless of whether that value is undefined or not.
This commit is contained in:
Jason Rudolph
2017-06-02 15:55:00 -04:00
parent 44a2be7c9d
commit 2347c9bdaa
2 changed files with 22 additions and 32 deletions

View File

@@ -690,13 +690,12 @@ module.exports = class Workspace extends Model {
// an active text editor.
//
// * `callback` {Function} to be called when the active text editor changes.
// * `editor` The active {TextEditor} or undefined if there is no longer an
// * `editor` The active {TextEditor} or undefined if there is not an
// active text editor.
//
// Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
observeActiveTextEditor (callback) {
const activeTextEditor = this.getActiveTextEditor()
if (activeTextEditor != null) { callback(activeTextEditor) }
callback(this.getActiveTextEditor())
return this.onDidChangeActiveTextEditor(callback)
}