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

Commit 75cf40c

Browse files
author
Michelle Tilley
committed
Add support for new pending item API
This adds backward-compatible checks for the new pending item APIs, and falls back to using `Item::terminatePendingState` if they're not supported in the current Atom environment.
1 parent fc2856a commit 75cf40c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/tree-view.coffee

Lines changed: 12 additions & 3 deletions
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) ->

0 commit comments

Comments
 (0)