Skip to content

Commit

Permalink
Enabling tree-view keyboard shortcuts for previewing files
Browse files Browse the repository at this point in the history
  • Loading branch information
piohhmy committed Mar 5, 2015
1 parent 46aecff commit 270d7c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions keymaps/sublime-tabs.cson
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
'ctrl-9': 'tree-view:open-selected-entry-in-pane-9'

'.tree-view':
'right': 'tree-view:expand-directory'
'ctrl-]': 'tree-view:expand-directory'
'l': 'tree-view:expand-directory'
'right': 'tree-view:expand-directory-or-preview-file'
'ctrl-]': 'tree-view:expand-directory-or-preview-file'
'l': 'tree-view:expand-directory-or-preview-file'
'left': 'tree-view:collapse-directory'
'ctrl-[': 'tree-view:collapse-directory'
'alt-ctrl-]': 'tree-view:recursive-expand-directory'
Expand Down
12 changes: 12 additions & 0 deletions lib/sublime-tree-view.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{$} = require 'atom'

TreeView = require atom.packages.resolvePackagePath('tree-view') + '/lib/tree-view'
DirectoryView = require atom.packages.resolvePackagePath('tree-view') + '/lib/directory-view'
FileView = require atom.packages.resolvePackagePath('tree-view') + '/lib/file-view'

module.exports =
class SublimeTreeView extends TreeView
initialize: (state) ->
super(state)

atom.commands.add '.tree-view',
'tree-view:expand-directory-or-preview-file', => @expandDirOrPreview()

@on 'dblclick', '.entry', (e) ->
return if e.shiftKey || e.metaKey || e.altKey
atom.workspaceView.find('.tab-bar .tab.active').removeClass('temp')
Expand All @@ -15,3 +20,10 @@ class SublimeTreeView extends TreeView
entryDblClicked: (e) ->
@selectedEntry = $(e.currentTarget).view()
@openSelectedEntry(false, true)

expandDirOrPreview: () ->
selectedEntry = @selectedEntry()
if selectedEntry instanceof DirectoryView
selectedEntry.expand(false)
else if selectedEntry instanceof FileView
atom.workspace.open(selectedEntry.getPath(), activatePane:false)

0 comments on commit 270d7c1

Please sign in to comment.