Handling commands in editors with `eachEditorView`


#1

I’m trying to add a language-specific feature. I do this by using workspaceView.eachEditorView and only subscribing commands to editors with the right grammar.

This works fine except for when I split the editor and have the same file open in multiple panes. The initial editor stops handling the command while the other editor with the same file continues to work.

Is this a bug?


#2

I don’t know if this will make any difference to your problem, but your code is deprecated. It should be …

atom.workspace.getTextEditors()

This will get the text editor models. Then to get an editor view (now a plain element) you use …

atom.views.getView(textEditor)

Maybe your problem can be solved by using observeTextEditors instead of getTextEditors. This will call you on each new editor creation.


#3

This worked! Thanks for the suggestion.