mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Tree view deselects entry when active item has no path
This commit is contained in:
@@ -127,8 +127,10 @@ class TreeView extends ScrollView
|
||||
@root = null
|
||||
|
||||
selectActiveFile: ->
|
||||
activeFilePath = rootView.getActiveView()?.getPath()
|
||||
@selectEntryForPath(activeFilePath) if activeFilePath
|
||||
if activeFilePath = rootView.getActiveView()?.getPath?()
|
||||
@selectEntryForPath(activeFilePath)
|
||||
else
|
||||
@deselect()
|
||||
|
||||
revealActiveFile: ->
|
||||
@attach()
|
||||
@@ -290,9 +292,12 @@ class TreeView extends ScrollView
|
||||
return false unless entry.get(0)
|
||||
entry = entry.view() unless entry instanceof View
|
||||
@selectedPath = entry.getPath()
|
||||
@treeViewList.find('.selected').removeClass('selected')
|
||||
@deselect()
|
||||
entry.addClass('selected')
|
||||
|
||||
deselect: ->
|
||||
@treeViewList.find('.selected').removeClass('selected')
|
||||
|
||||
scrollTop: (top) ->
|
||||
if top
|
||||
@treeViewList.scrollTop(top)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
_ = require 'underscore'
|
||||
TreeView = require 'tree-view/lib/tree-view'
|
||||
RootView = require 'root-view'
|
||||
@@ -301,18 +302,25 @@ describe "TreeView", ->
|
||||
expect(subdir).toHaveClass 'expanded'
|
||||
expect(rootView.getActiveView().isFocused).toBeFalsy()
|
||||
|
||||
describe "when a new file is opened in the active editor", ->
|
||||
it "selects the file in the tree view if the file's entry visible", ->
|
||||
sampleJs.click()
|
||||
rootView.open(require.resolve('fixtures/tree-view/tree-view.txt'))
|
||||
describe "when the active item changes on the active pane", ->
|
||||
describe "when the item has a path", ->
|
||||
it "selects the entry with that path in the tree view if it is visible", ->
|
||||
sampleJs.click()
|
||||
rootView.open(require.resolve('fixtures/tree-view/tree-view.txt'))
|
||||
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
|
||||
it "selects the file's parent dir if the file's entry is not visible", ->
|
||||
rootView.open('dir1/sub-dir1/sub-file1')
|
||||
dirView = treeView.root.find('.directory:contains(dir1)').view()
|
||||
expect(dirView).toHaveClass 'selected'
|
||||
it "selects the path's parent dir if its entry is not visible", ->
|
||||
rootView.open('dir1/sub-dir1/sub-file1')
|
||||
dirView = treeView.root.find('.directory:contains(dir1)').view()
|
||||
expect(dirView).toHaveClass 'selected'
|
||||
|
||||
describe "when the item has no path", ->
|
||||
it "deselects the previously selected entry", ->
|
||||
sampleJs.click()
|
||||
rootView.getActivePane().showItem($$ -> @div('hello'))
|
||||
expect(rootView.find('.selected')).not.toExist()
|
||||
|
||||
describe "when a different editor becomes active", ->
|
||||
it "selects the file in that is open in that editor", ->
|
||||
|
||||
Reference in New Issue
Block a user