mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user