Use the tree-view in Atom editor init script

不想你离开。 提交于 2019-12-06 09:44:08

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:

atom.commands.add 'atom-editor', 'custom:show-active-file', ->
  atom.commands.dispatch(atom.workspaceView.element, 'tree-view:toggle-focus')
  atom.commands.dispatch(atom.workspaceView.element, 'tree-view:reveal-active-file')

Sadly, Lee's answer is not correct anymore. Within changes in the API the changed the naming of atom.workspaceView to atom.workspace.

So, if anyone gets here (sure questions and answer is a "bit" old), here's the current working script.

atom.commands.add 'atom-editor', 'custom:show-active-file', ->
atom.commands.dispatch(atom.workspace.element, 'tree-view:toggle-focus')
atom.commands.dispatch(atom.workspace.element, 'tree-view:reveal-active-file')

@Source
https://discuss.atom.io/t/workspaceview-events/14595/4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!