Workspace.observeTextEditors does not apply


#1

Hello everyone. I’m trying to write small package which will modify a textEditor every time file gets opened. So as I understood separate TextEditor created for each tab in editor and I need to observe creation of new text editors and apply my function with it. https://atom.io/docs/api/v1.0.0/Workspace#instance-observeTextEditors recommends me to use “observeTextEditors” event but it does not applies at all. Here is my package code:

activate: (state) ->
    atom.workspace.observeTextEditors (event) =>
      console.log 'called'

When I open any file console log is empty. What I’m doing wrong?


#2

I would guess your package is not getting activated. If there are no activation events in your package.json then it should be activated upon restart. If there are events (commands/keybindings) then it won’t be activated until the key is pressed.

You can use my package-cop to inspect activation state of packages. Let me know if you need help.