Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
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
2 changes: 1 addition & 1 deletion lib/tree-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class TreeView extends View
else if entry instanceof FileView
detail = e.originalEvent?.detail ? 1
if detail is 1
if atom.config.get('core.allowPendingPaneItems')
if atom.config.get('core.allowPendingPaneItems') or atom.config.get('tree-view.openFilesWithSingleClick')
atom.workspace.open(entry.getPath(), pending: true, activatePane: false)
else if detail is 2
atom.workspace.open(entry.getPath())
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"type": "boolean",
"default": true,
"description": "Focus the tree view when revealing entries."
},
"openFilesWithSingleClick": {
"type": "boolean",
"default": false,
"title": "Open files with single-click",
"description": "Open files with a single-click instead of a double-click."
}
}
}
13 changes: 13 additions & 0 deletions spec/tree-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe "TreeView", ->

beforeEach ->
expect(atom.config.get('core.allowPendingPaneItems')).toBeTruthy()
expect(atom.config.get('tree-view.openFilesWithSingleClick')).toBeFalsy()

fixturesPath = atom.project.getPaths()[0]
path1 = path.join(fixturesPath, "root-dir1")
Expand Down Expand Up @@ -623,6 +624,18 @@ describe "TreeView", ->

it "does not open the file", ->
expect(atom.workspace.open).not.toHaveBeenCalled()

describe "when tree-view.openFilesWithSingleClick is set to true", ->
beforeEach ->
atom.config.set('core.allowPendingPaneItems', false)
atom.config.set('tree-view.openFilesWithSingleClick', true)
spyOn(atom.workspace, 'open')

treeView.focus()
sampleJs.trigger clickEvent(originalEvent: {detail: 1})

it "opens the file immediately upon selection", ->
expect(atom.workspace.open).toHaveBeenCalled()

describe "when a file is double-clicked", ->
activePaneItem = null
Expand Down