In EditorManager.js, it says: "focusedEditorChange -- When the focused editor (full or inline) changes and size/visibility are complete"
In the same file, function createInlineEditorForDocument is documented as "Creates a new inline Editor instance for the given Document. [...] The editor is not yet visible or attached to a host editor." Yet, this function triggers the focusedEditorChange event.
Consequently, if a handler then calls getFocusedEditor() it will get the editor that is about to lose focus, not the one that just got focus. Since the focusedEditorChange event does not pass along the editor it replaces, this behavior could be relied upon to determine which editor previously had focus. But depending on which part of the documentation is correct, this behavior could change.
Also, an event handler for focusedEditorChange might call a function that is otherwise independent of the event and therefore needs to call getFocusedEditor(). It would then not get the editor that now has focus.
In my opinion focusedEditorChange should only be triggered when the new editor is visible and actually has the focus - as documented. getFocusedEditor() would then return the same editor as passed on by the event.
In addition, I would pass the previously focused editor to the handler function as well.
function onFocusedEditorChange(event, editor, previousEditor)
In EditorManager.js, it says: "focusedEditorChange -- When the focused editor (full or inline) changes and size/visibility are complete"
In the same file, function createInlineEditorForDocument is documented as "Creates a new inline Editor instance for the given Document. [...] The editor is not yet visible or attached to a host editor." Yet, this function triggers the focusedEditorChange event.
Consequently, if a handler then calls getFocusedEditor() it will get the editor that is about to lose focus, not the one that just got focus. Since the focusedEditorChange event does not pass along the editor it replaces, this behavior could be relied upon to determine which editor previously had focus. But depending on which part of the documentation is correct, this behavior could change.
Also, an event handler for focusedEditorChange might call a function that is otherwise independent of the event and therefore needs to call getFocusedEditor(). It would then not get the editor that now has focus.
In my opinion focusedEditorChange should only be triggered when the new editor is visible and actually has the focus - as documented. getFocusedEditor() would then return the same editor as passed on by the event.
In addition, I would pass the previously focused editor to the handler function as well.