I'm trying to write a init script for the Atom editor to add a custom command to be able to reveal the currently opened editor file in the tree-view with one key combination, instead of two.
Here is an example code (which makes something different) to make clear how it generally has to look like.
atom.commands.add 'atom-editor', 'custom:cut-line', ->
editor = atom.workspace.getActiveEditor()
editor.selectLine()
editor.cutSelectedText()
The two commands I need should not be sent to the editor
, but to the tree-view
. Here are the two commands:
tree-view:toggle-focus
tree-view:reveal-active-file
I assume I have to do something similar as above, like getActiveTreeView
or something like that. I tried to google it but it doesn't seem to be obvious. Does someone know how to do this?
It could look something like this:
atom.commands.add 'atom-editor', 'custom:show-active-file', ->
tree-view.toggle-focus()
tree-view.reveal-active-file()
You can use the
atom.commands.dispatch()
method to send a command when getting a hold of the object to send the commands to is hard. In your case, you can use: