Terminate pending state for opened file if pending option is false

This commit is contained in:
Katrina Uychaco
2016-02-17 14:14:59 -08:00
parent 912df0ae03
commit a146401f21
2 changed files with 18 additions and 1 deletions

View File

@@ -585,6 +585,22 @@ describe "Workspace", ->
open = -> workspace.open('file1', workspace.getActivePane())
expect(open).toThrow()
describe "when the file is already open in pending state", ->
it "should terminate the pending state", ->
editor = null
waitsForPromise ->
atom.workspace.open('sample.js', pending: true).then (o) -> editor = o
runs ->
expect(editor.isPending()).toBe true
waitsForPromise ->
atom.workspace.open('sample.js').then (o) -> editor = o
runs ->
expect(editor.isPending()).toBe false
describe "::reopenItem()", ->
it "opens the uri associated with the last closed pane that isn't currently open", ->
pane = workspace.getActivePane()

View File

@@ -476,7 +476,8 @@ class Workspace extends Model
activateItem = options.activateItem ? true
if uri?
item = pane.itemForURI(uri)
if item = pane.itemForURI(uri)
item.terminatePendingState?() if item.isPending?() and not options.pending
item ?= opener(uri, options) for opener in @getOpeners() when not item
try