Handling commands in editors with `eachEditorView`


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?


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


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


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


This worked! Thanks for the suggestion.