Documentation: workspace.activeTextEditor can be undefined

workspace.activeTextEditor is undefined if the active tab is a file browser, terminal, or live preview.

Documentation does not mention that it can be undefined. This has repercussions for the Nova extension Typescript definitions which failed to include this as it wasn’t documented.

Thank you for the report, Austen!

I’ve clarified this documentation and pushed an update.

Logan

Thanks for the documentation update @logan

Documentation says it can be null, but console reports undefined. So I wondered if the console just logs undefined, even though it’s really null. So I tested it, a null variable logs null, and undefined logs undefined. So is activeTextEditor really null? Or is it undefined?

It’s the same situation for workspace.path too.

Wanting to know so the nova extension typescript definitions can be accurate.

This is a consequence of using Apple’s JavaScriptCore and its Objective-C bridge (as Nova’s extension runtime is implemented in Objective-C, and bridged into JavaScript). It treats null and undefined as effectively the same thing in a lot of cases.

We attempt to ensure it’s one or the other in a lot of cases, but most of the time if it can be null, it can also be undefined.