From 902be145420dcc3443868bfc2608b04f0e71582b Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Wed, 17 Feb 2016 15:36:06 -0800 Subject: [PATCH 1/2] On second click, open without `pending` option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With https://github.com/atom/atom/pull/10872 it’s no longer necessary to explicitly `terminatePendingState` here --- lib/tree-view.coffee | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/tree-view.coffee b/lib/tree-view.coffee index 5fceed45..52167426 100644 --- a/lib/tree-view.coffee +++ b/lib/tree-view.coffee @@ -208,12 +208,12 @@ class TreeView extends View if entry.getPath() is atom.workspace.getActivePaneItem()?.getPath?() @focus() else - @openedItem = atom.workspace.open(entry.getPath(), pending: true) + atom.workspace.open(entry.getPath(), pending: true) else if entry instanceof DirectoryView entry.toggleExpansion(isRecursive) when 2 if entry instanceof FileView - @openedItem.then((item) -> item.terminatePendingState?()) + atom.workspace.open(entry.getPath()) unless entry.getPath() is atom.workspace.getActivePaneItem()?.getPath?() @unfocus() else if entry instanceof DirectoryView @@ -392,11 +392,7 @@ class TreeView extends View else selectedEntry.toggleExpansion() else if selectedEntry instanceof FileView - uri = selectedEntry.getPath() - item = atom.workspace.getActivePane()?.itemForURI(uri) - if item? and not options.pending - item.terminatePendingState?() - atom.workspace.open(uri, options) + atom.workspace.open(selectedEntry.getPath(), options) openSelectedEntrySplit: (orientation, side) -> selectedEntry = @selectedEntry() From 0f8432c99ee025a857720760e7810b9e1a834319 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sun, 28 Feb 2016 17:10:39 -0800 Subject: [PATCH 2/2] Update and fix specs for pending state --- spec/tree-view-spec.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/tree-view-spec.coffee b/spec/tree-view-spec.coffee index 6b182db3..4644aa78 100644 --- a/spec/tree-view-spec.coffee +++ b/spec/tree-view-spec.coffee @@ -526,7 +526,7 @@ describe "TreeView", -> sampleJs.mousedown() expect(sampleJs).toHaveClass 'selected' - if atom.workspace.buildTextEditor().isPending? + if atom.workspace.getActivePane().getPendingItem? describe "when files are clicked", -> beforeEach -> jasmine.attachToDOM(workspaceElement) @@ -548,7 +548,7 @@ describe "TreeView", -> it "opens it in the pane in pending state", -> expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js') - expect(activePaneItem.isPending()).toBe true + expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem it "changes the focus to the file", -> expect(atom.views.getView(activePaneItem)).toHaveFocus() @@ -584,18 +584,18 @@ describe "TreeView", -> it "opens it in pending state on first click", -> expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js') - expect(activePaneItem.isPending()).toBe true + expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem it "terminates pending state on second click", -> sampleJs.trigger clickEvent(originalEvent: {detail: 2}) waitsFor -> - activePaneItem.isPending() is false + atom.workspace.getActivePane().getPendingItem() isnt activePaneItem it "does not create pending state on subsequent single click", -> sampleJs.trigger clickEvent(originalEvent: {detail: 2}) sampleJs.trigger clickEvent(originalEvent: {detail: 1}) waitsFor -> - activePaneItem.isPending() is false + atom.workspace.getActivePane().getPendingItem() isnt activePaneItem describe "when a file is single-clicked, then double-clicked", -> activePaneItem = null @@ -611,13 +611,13 @@ describe "TreeView", -> it "opens it in pending state on single-click", -> expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js') - expect(activePaneItem.isPending()).toBe true + expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem it "terminates pending state on the double-click and focuses file", -> sampleJs.trigger clickEvent(originalEvent: {detail: 2}) expect(atom.views.getView(activePaneItem)).toHaveFocus() waitsFor -> - activePaneItem.isPending() is false + atom.workspace.getActivePane().getPendingItem() isnt activePaneItem it "keeps focus on tree-view if the file is the active pane item", -> sampleJs.trigger clickEvent(originalEvent: {detail: 1})