Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Make 'preview files' to work with up/down arrow keys #834

Open
0xdevalias opened this issue May 12, 2016 · 8 comments
Open

Make 'preview files' to work with up/down arrow keys #834

0xdevalias opened this issue May 12, 2016 · 8 comments

Comments

@0xdevalias
Copy link

0xdevalias commented May 12, 2016

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.

@0xdevalias 0xdevalias changed the title Allow 'preview files' to work with arrow keys Make 'preview files' to work with up/down arrow keys May 12, 2016
@EvanBurchard
Copy link

👍

1 similar comment
@cpatti97100
Copy link

+1

@pinps
Copy link

pinps commented Jul 14, 2016

👍
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

@tuckerconnelly
Copy link

If you have your tree view on the right side of your workspace, make sure you use getRightPanels instead of getLeftPanels

@ThomasChaf
Copy link

ThomasChaf commented Sep 6, 2017

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.

@yarozar
Copy link

yarozar commented Nov 21, 2018

Any chance to have it done any time soon? It is "Open" for 2.5 years now...

@EditorJack
Copy link

Thank you so much! This is great!

@jefferyyuan
Copy link

jefferyyuan commented May 19, 2019

This would be very useful, please add this feature.
Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants