From 8bf16ba60272cd15c334d935e4ea24c07cd49b57 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 10 Jan 2013 15:39:32 -0800 Subject: [PATCH] Don't attach the tree view when a project path changes The tree view shouldn't automatically open when the project first gets a path after not having one. It can be still be toggled to be opened once the project has a path. --- .../tree-view/spec/tree-view-spec.coffee | 17 ++--------------- src/packages/tree-view/src/tree-view.coffee | 7 ++----- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/packages/tree-view/spec/tree-view-spec.coffee b/src/packages/tree-view/spec/tree-view-spec.coffee index f323100d7..0ead23590 100644 --- a/src/packages/tree-view/spec/tree-view-spec.coffee +++ b/src/packages/tree-view/spec/tree-view-spec.coffee @@ -66,23 +66,10 @@ describe "TreeView", -> it "serializes without throwing an exception", -> expect(-> treeView.serialize()).not.toThrow() - describe "when the project is assigned a path because a buffer is opened", -> - it "attaches the tree and creates a root directory view", -> - rootView.open(require.resolve('fixtures/sample.js')) - expect(treeView.hasParent()).toBeTruthy() - expect(treeView.root.getPath()).toBe require.resolve('fixtures') - expect(treeView.root.parent()).toMatchSelector(".tree-view") - - oldRoot = treeView.root - - rootView.project.setPath('/tmp') - expect(treeView.root).not.toEqual oldRoot - expect(oldRoot.hasParent()).toBeFalsy() - describe "when the project is assigned a path because a new buffer is saved", -> - it "attaches the tree and creates a root directory view", -> + it "creates a root directory view but does not attach to the root view", -> rootView.getActiveEditSession().saveAs("/tmp/test.txt") - expect(treeView.hasParent()).toBeTruthy() + expect(treeView.hasParent()).toBeFalsy() expect(treeView.root.getPath()).toBe require.resolve('/tmp') expect(treeView.root.parent()).toMatchSelector(".tree-view") diff --git a/src/packages/tree-view/src/tree-view.coffee b/src/packages/tree-view/src/tree-view.coffee index af7a893f0..a07a4bb7a 100644 --- a/src/packages/tree-view/src/tree-view.coffee +++ b/src/packages/tree-view/src/tree-view.coffee @@ -17,11 +17,8 @@ class TreeView extends ScrollView else @instance = new TreeView(rootView) - if rootView.project.getPath() - @instance.attach() unless rootView.pathToOpenIsFile - else - rootView.project.one "path-changed", => - @instance.attach() + if rootView.project.getPath() and not rootView.pathToOpenIsFile + @instance.attach() @deactivate: -> @instance.deactivate()