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

add new open-selected-entry-without-activate command #905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions keymaps/tree-view.cson
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
'alt-left': 'tree-view:recursive-collapse-directory'
'h': 'tree-view:collapse-directory'
'enter': 'tree-view:open-selected-entry'
'o': 'tree-view:open-selected-entry-without-activate'
'ctrl-C': 'tree-view:copy-full-path'
'm': 'tree-view:move'
'f2': 'tree-view:move'
Expand Down
1 change: 1 addition & 0 deletions lib/tree-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class TreeView extends View
'tree-view:collapse-directory': => @collapseDirectory()
'tree-view:recursive-collapse-directory': => @collapseDirectory(true)
'tree-view:open-selected-entry': => @openSelectedEntry()
'tree-view:open-selected-entry-without-activate': => @openSelectedEntry(pending: true, activatePane: false)
'tree-view:open-selected-entry-right': => @openSelectedEntryRight()
'tree-view:open-selected-entry-left': => @openSelectedEntryLeft()
'tree-view:open-selected-entry-up': => @openSelectedEntryUp()
Expand Down
25 changes: 25 additions & 0 deletions spec/tree-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,31 @@ describe "TreeView", ->
atom.commands.dispatch(treeView.element, 'tree-view:open-selected-entry')
expect(atom.workspace.getActivePaneItem()).toBeUndefined()

describe "tree-view:open-selected-entry-without-activate", ->
ensurePreviewOpen = (fileName) ->
runs ->
file = root1.find(".file:contains(#{fileName})")[0]
treeView.selectEntry(file)

waitsForFileToOpen ->
atom.commands.dispatch(treeView.element, 'tree-view:open-selected-entry-without-activate')

runs ->
item = atom.workspace.getActivePaneItem()
expect(item.getPath()).toBe atom.project.getDirectories()[0].resolve(fileName)
expect(atom.views.getView(item)).not.toHaveFocus()
expect(atom.workspace.getActivePane().getPendingItem()).toEqual(item)
expect(treeView).toHaveFocus()

beforeEach ->
jasmine.attachToDOM(workspaceElement)
treeView.focus()
expect(treeView).toHaveFocus()

it "opens the file with pending state and focus remains on treeView", ->
ensurePreviewOpen('tree-view.js')
ensurePreviewOpen('tree-view.txt')

describe "opening in new split panes", ->
splitOptions =
right: ['horizontal', 'after']
Expand Down