Make 'preview files' to work with up/down arrow keys
0xdevalias opened this issue ยท 8 comments
When using the file preview feature, you can't use the up/down arrow keys to quickly flick through files (Sublime has this feature)
It seems by pressing the right arrow key you can open the currently selected file, but this doesn't help when wanting to quickly scan through a bunch of files.
๐
+1
๐
While waiting created a workaround for this. Just add following to your init.coffee and keymap.cson
init.coffee
atom.commands.add '.tree-view', 'custom:expand-item-down': ->
fs = require 'fs'
for panel in atom.workspace.getLeftPanels()
if panel.item.constructor.name == "TreeView"
atom.commands.dispatch(panel.item.element, 'core:move-down')
if fs.lstatSync(panel.item.selectedPath).isDirectory()
return
else
panel.item.openSelectedEntry(pending: true, activatePane: false)
return
atom.commands.add '.tree-view', 'custom:expand-item-up': ->
fs = require 'fs'
for panel in atom.workspace.getLeftPanels()
if panel.item.constructor.name == "TreeView"
atom.commands.dispatch(panel.item.element, 'core:move-up')
if fs.lstatSync(panel.item.selectedPath).isDirectory()
return
else
panel.item.openSelectedEntry(pending: true, activatePane: false)
return
keymap.cson
'.tree-view':
'down': 'custom:expand-item-down',
'up': 'custom:expand-item-up'
edit: require fs instead of fs-plust as it is not installed by default
If you have your tree view on the right side of your workspace, make sure you use getRightPanels
instead of getLeftPanels
pinps workaround wasn't working because getLeftPanels gave me an empty array. (my tree-view is on the left)
So here is my workaround according to pinps idea :
init.coffee
atom.commands.add '.tree-view', 'custom:expand-item-down': ->
fs = require 'fs'
item = atom.workspace.getActivePaneItem()
atom.commands.dispatch(item.element, 'core:move-down')
if fs.lstatSync(item.selectedPath).isDirectory()
return
else
item.openSelectedEntry(pending: true, activatePane: false)
return
atom.commands.add '.tree-view', 'custom:expand-item-up': ->
fs = require 'fs'
item = atom.workspace.getActivePaneItem()
atom.commands.dispatch(item.element, 'core:move-up')
if fs.lstatSync(item.selectedPath).isDirectory()
return
else
item.openSelectedEntry(pending: true, activatePane: false)
return
I'm not really sure it's working on every situation but I still post this here because I realised we could get the item easier and this could interest some of you guys.
keymap.cson
same as pinps.
Any chance to have it done any time soon? It is "Open" for 2.5 years now...
Thank you so much! This is great!
This would be very useful, please add this feature.
Thanks.