Observe currentlyActiveTextEditor?


I need to listen to “currentlyActiveTextEditor”. Use case is that I need to support multiple project.paths having different client+server backend for IDE features: https://github.com/ensime/ensime-atom/issues/30

So the idea is just to have our own registry for of project.paths -> backend-client and for file actions we can just look up current buffers client by using:


and lookup against

Will be O(n) against number of paths in a project, but should be ok since you don’t use many. Is there any O(1) lookup like “getProjectRootPathOfFile” or something like that?

But the big issue is that we need to watch for current active editor to switch out the “errors/warnings” pane at the bottom to the project this file belongs to. I found:

but that’s for all kinds of panes? I want something like getCurrentActiveTextEditor but event driven.

https://atom.io/docs/api/v1.1.0/Workspace#instance-observeTextEditors isn’t called when simply switching to an existing editor, right?


You’re looking for atom.workspace.onDidChangeActivePaneItem or perhaps atom.workspace.onDidStopChangingActivePaneItem.


Thanks! Seems to do the trick.