From a146401f21dfb7804799a9420d1b891975297022 Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Wed, 17 Feb 2016 14:14:59 -0800 Subject: [PATCH] Terminate pending state for opened file if pending option is false --- spec/workspace-spec.coffee | 16 ++++++++++++++++ src/workspace.coffee | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 534f2bf61..ef89636a8 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -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() diff --git a/src/workspace.coffee b/src/workspace.coffee index b26383786..0bfff7e0f 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -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