diff --git a/keymaps/tree-view.cson b/keymaps/tree-view.cson index 08c943c0..d8c28345 100644 --- a/keymaps/tree-view.cson +++ b/keymaps/tree-view.cson @@ -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' diff --git a/lib/tree-view.coffee b/lib/tree-view.coffee index 5abf3031..4b1d136b 100644 --- a/lib/tree-view.coffee +++ b/lib/tree-view.coffee @@ -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() diff --git a/spec/tree-view-spec.coffee b/spec/tree-view-spec.coffee index df5b5798..1109c8b3 100644 --- a/spec/tree-view-spec.coffee +++ b/spec/tree-view-spec.coffee @@ -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']