diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 41cfae18c..8faaf44c2 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -179,7 +179,7 @@ fdescribe "Workspace", -> runs -> expect(newEditorHandler).toHaveBeenCalledWith editor - describe "::reopenItemSync()", -> + describe "::reopenItem()", -> it "opens the uri associated with the last closed pane that isn't currently open", -> pane = workspace.activePane waitsForPromise -> @@ -192,7 +192,11 @@ fdescribe "Workspace", -> # does not reopen items with no uri expect(workspace.activePaneItem.getUri()).toBeUndefined() pane.destroyActiveItem() - workspace.reopenItemSync() + + waitsForPromise -> + workspace.reopenItem() + + runs -> expect(workspace.activePaneItem.getUri()).not.toBeUndefined() # destroy all items @@ -205,7 +209,11 @@ fdescribe "Workspace", -> # reopens items with uris expect(workspace.activePaneItem).toBeUndefined() - workspace.reopenItemSync() + + waitsForPromise -> + workspace.reopenItem() + + runs -> expect(workspace.activePaneItem.getUri()).toBe atom.project.resolve('a') # does not reopen items that are already open @@ -214,7 +222,11 @@ fdescribe "Workspace", -> runs -> expect(workspace.activePaneItem.getUri()).toBe atom.project.resolve('b') - workspace.reopenItemSync() + + waitsForPromise -> + workspace.reopenItem() + + runs -> expect(workspace.activePaneItem.getUri()).toBe atom.project.resolve('file1') describe "::increase/decreaseFontSize()", -> diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index c4bcaad36..082de77f8 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -57,7 +57,7 @@ class WorkspaceView extends View Delegator.includeInto(this) @delegatesProperty 'fullScreen', 'destroyedItemUris', toProperty: 'model' - @delegatesMethods 'open', 'openSync', 'reopenItemSync', + @delegatesMethods 'open', 'openSync', 'saveActivePaneItem', 'saveActivePaneItemAs', 'saveAll', 'destroyActivePaneItem', 'destroyActivePane', 'increaseFontSize', 'decreaseFontSize', toProperty: 'model' @@ -149,7 +149,7 @@ class WorkspaceView extends View @command 'window:toggle-auto-indent', => atom.config.toggle("editor.autoIndent") - @command 'pane:reopen-closed-item', => @reopenItemSync() + @command 'pane:reopen-closed-item', => @getModel().reopenItem() @command 'core:close', => if @getModel().getActivePaneItem()? then @destroyActivePaneItem() else @destroyActivePane() @command 'core:save', => @saveActivePaneItem() diff --git a/src/workspace.coffee b/src/workspace.coffee index cc29853b0..f5ddd9115 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -167,9 +167,13 @@ class Workspace extends Model # Public: Reopen the last-closed item's URI if it hasn't already been # reopened. - reopenItemSync: -> + # + # Returns a promise that is resolved when the item is opened + reopenItem: -> if uri = @destroyedItemUris.pop() - @openSync(uri) + @open(uri) + else + Q() # Public: Register an opener for a uri. #