Refactor pending state to live in pane instead of items

* New public API `workspace.setItemNotPending` that
  packages can use to set an item to set an item to not pending
  (e.g. when the user interacts with the item)
* Pending state for newly opened items with `{pending: true}`
  is now tracked by `Pane` instead of the item, and packages like
  `tabs` that query this information now get it from the Pane.
This commit is contained in:
Katrina Uychaco
2016-02-24 18:19:13 -08:00
parent 606dc0299c
commit a487110521
3 changed files with 41 additions and 27 deletions

View File

@@ -477,7 +477,7 @@ class Workspace extends Model
if uri?
if item = pane.itemForURI(uri)
item.terminatePendingState?() if item.isPending?() and not options.pending
pane.setPendingItem(null) if not options.pending
item ?= opener(uri, options) for opener in @getOpeners() when not item
try
@@ -500,7 +500,7 @@ class Workspace extends Model
return item if pane.isDestroyed()
@itemOpened(item)
pane.activateItem(item) if activateItem
pane.activateItem(item, options.pending) if activateItem
pane.activate() if activatePane
initialLine = initialColumn = 0
@@ -515,6 +515,12 @@ class Workspace extends Model
@emitter.emit 'did-open', {uri, pane, item, index}
item
setItemNotPending: (item) =>
for pane in @getPanes()
if item is pane.getPendingItem()
pane.setPendingItem(null)
break
openTextFile: (uri, options) ->
filePath = @project.resolvePath(uri)