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

allow turning off auto tracking of active pane #1336

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
9 changes: 7 additions & 2 deletions lib/tree-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,13 @@ class TreeView
@openSelectedEntryInPane index

@disposables.add atom.workspace.getCenter().onDidChangeActivePaneItem =>
@selectActiveFile()
@revealActiveFile({show: false, focus: false}) if atom.config.get('tree-view.autoReveal')
# migrate old tree-view.autoReveal config
if atom.config.get 'tree-view.autoReveal'
atom.config.set 'tree-view.autoTrackActivePane.autoReveal', true
atom.config.unset 'tree-view.autoReveal'
autoTrackActivePane = atom.config.get('tree-view.autoTrackActivePane.enabled')
@selectActiveFile() if autoTrackActivePane
@revealActiveFile({show: false, focus: false}) if autoTrackActivePane and atom.config.get('tree-view.autoTrackActivePane.autoReveal')
@disposables.add atom.project.onDidChangePaths =>
@updateRoots()
@disposables.add atom.config.onDidChange 'tree-view.hideVcsIgnoredFiles', =>
Expand Down
26 changes: 21 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,31 @@
"default": true,
"description": "When listing directory items, list subdirectories before listing files."
},
"autoReveal": {
"type": "boolean",
"default": false,
"description": "Reveal tree view entries when they become the active pane item."
"autoTrackActivePane": {
"type": "object",
"title": "Auto Select Active Pane",
"description": "The Active Pane is typically the focused editor buffer",
"properties": {
"enabled": {
"order": 1,
"title": "Enabled",
"type": "boolean",
"default": true,
"description": "Change the selected tree node to reflect the active pane item as it changes."
},
"autoReveal": {
"order": 2,
"title": "Auto Reveal",
"type": "boolean",
"default": false,
"description": "If the new tree selection is not visible, expand and scroll as needed to reveal it into view."
}
}
},
"focusOnReveal": {
"type": "boolean",
"default": true,
"description": "Focus the tree view when revealing entries."
"description": "Make the `Reveal Active File` command focus the tree view after it selects and reveals the active pane item"
},
"alwaysOpenExisting": {
"type": "boolean",
Expand Down
25 changes: 23 additions & 2 deletions spec/tree-view-package-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,10 @@ describe "TreeView", ->
dirView = root1.querySelector('.directory')
expect(dirView).toHaveClass 'selected'

describe "when the tree-view.autoReveal config setting is true", ->
describe "when the tree-view.autoTrackActivePane.autoReveal config setting is true", ->
beforeEach ->
jasmine.attachToDOM(atom.workspace.getElement())
atom.config.set "tree-view.autoReveal", true
atom.config.set "tree-view.autoTrackActivePane.autoReveal", true

it "selects the active item's entry in the tree view, expanding parent directories if needed", ->
waitsForPromise ->
Expand All @@ -791,6 +791,27 @@ describe "TreeView", ->
runs ->
expect(atom.workspace.getActiveTextEditor().getElement()).toHaveFocus()

describe "when the tree-view.autoTrackActivePane.enabled config setting is false", ->
beforeEach ->
jasmine.attachToDOM(atom.workspace.getElement())
atom.config.set "tree-view.autoTrackActivePane.enabled", false

it "does not change the selection", ->
currentSelection = treeView.getSelectedEntries()[0].textContent
console.log "currentSelection="+currentSelection
done = false
disposable = atom.workspace.getCenter().onDidChangeActivePaneItem =>
disposable.dispose()
done = true

waitsForPromise ->
atom.workspace.open(path.join('dir1', 'sub-dir1', 'sub-file1'))

waitsFor -> done

runs ->
expect(treeView.getSelectedEntries()[0].textContent).toBe(currentSelection)

describe "when a different editor becomes active", ->
beforeEach ->
jasmine.attachToDOM(workspaceElement)
Expand Down