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

Commit 5f4923f

Browse files
author
Michelle Tilley
committed
Merge pull request #752 from atom/mt-fix-cant-open-multiple-non-text-files
Add backward-compatible support for new pending item API
2 parents fc2856a + 1bab87f commit 5f4923f

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

lib/tree-view.coffee

+12-3
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ class TreeView extends View
213213
entry.toggleExpansion(isRecursive)
214214
when 2
215215
if entry instanceof FileView
216-
@openedItem.then((item) -> item.terminatePendingState?())
216+
@openedItem.then (item) ->
217+
activePane = atom.workspace.getActivePane()
218+
if activePane?.getPendingItem?
219+
activePane.clearPendingItem() if activePane.getPendingItem() is item
220+
else if item.terminatePendingState?
221+
item.terminatePendingState()
217222
unless entry.getPath() is atom.workspace.getActivePaneItem()?.getPath?()
218223
@unfocus()
219224
else if entry instanceof DirectoryView
@@ -393,9 +398,13 @@ class TreeView extends View
393398
selectedEntry.toggleExpansion()
394399
else if selectedEntry instanceof FileView
395400
uri = selectedEntry.getPath()
396-
item = atom.workspace.getActivePane()?.itemForURI(uri)
401+
activePane = atom.workspace.getActivePane()
402+
item = activePane?.itemForURI(uri)
397403
if item? and not options.pending
398-
item.terminatePendingState?()
404+
if activePane?.getPendingItem?
405+
activePane.clearPendingItem() if activePane.getPendingItem() is item
406+
else if item.terminatePendingState?
407+
item.terminatePendingState()
399408
atom.workspace.open(uri, options)
400409

401410
openSelectedEntrySplit: (orientation, side) ->

spec/tree-view-spec.coffee

+7-7
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ describe "TreeView", ->
526526
sampleJs.mousedown()
527527
expect(sampleJs).toHaveClass 'selected'
528528

529-
if atom.workspace.buildTextEditor().isPending?
529+
if atom.workspace.getActivePane().getPendingItem?
530530
describe "when files are clicked", ->
531531
beforeEach ->
532532
jasmine.attachToDOM(workspaceElement)
@@ -548,7 +548,7 @@ describe "TreeView", ->
548548

549549
it "opens it in the pane in pending state", ->
550550
expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js')
551-
expect(activePaneItem.isPending()).toBe true
551+
expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem
552552

553553
it "changes the focus to the file", ->
554554
expect(atom.views.getView(activePaneItem)).toHaveFocus()
@@ -584,18 +584,18 @@ describe "TreeView", ->
584584

585585
it "opens it in pending state on first click", ->
586586
expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js')
587-
expect(activePaneItem.isPending()).toBe true
587+
expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem
588588

589589
it "terminates pending state on second click", ->
590590
sampleJs.trigger clickEvent(originalEvent: {detail: 2})
591591
waitsFor ->
592-
activePaneItem.isPending() is false
592+
atom.workspace.getActivePane().getPendingItem() isnt activePaneItem
593593

594594
it "does not create pending state on subsequent single click", ->
595595
sampleJs.trigger clickEvent(originalEvent: {detail: 2})
596596
sampleJs.trigger clickEvent(originalEvent: {detail: 1})
597597
waitsFor ->
598-
activePaneItem.isPending() is false
598+
atom.workspace.getActivePane().getPendingItem() isnt activePaneItem
599599

600600
describe "when a file is single-clicked, then double-clicked", ->
601601
activePaneItem = null
@@ -611,13 +611,13 @@ describe "TreeView", ->
611611

612612
it "opens it in pending state on single-click", ->
613613
expect(activePaneItem.getPath()).toBe atom.project.getDirectories()[0].resolve('tree-view.js')
614-
expect(activePaneItem.isPending()).toBe true
614+
expect(atom.workspace.getActivePane().getPendingItem()).toEqual activePaneItem
615615

616616
it "terminates pending state on the double-click and focuses file", ->
617617
sampleJs.trigger clickEvent(originalEvent: {detail: 2})
618618
expect(atom.views.getView(activePaneItem)).toHaveFocus()
619619
waitsFor ->
620-
activePaneItem.isPending() is false
620+
atom.workspace.getActivePane().getPendingItem() isnt activePaneItem
621621

622622
it "keeps focus on tree-view if the file is the active pane item", ->
623623
sampleJs.trigger clickEvent(originalEvent: {detail: 1})

0 commit comments

Comments
 (0)