From 27c03ae3f37d37a294b4ec54dec3ddb8586f8cb5 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 13 Jan 2014 18:26:00 -0700 Subject: [PATCH] Move management of destroyedItemUris to Workspace model --- src/workspace-view.coffee | 16 ++-------------- src/workspace.coffee | 11 ++++++++++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 5ab19c9bc..c89266d88 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -44,7 +44,8 @@ class WorkspaceView extends View Serializable.includeInto(this) Delegator.includeInto(this) - @delegatesProperty 'fullScreen', toProperty: 'model' + @delegatesProperty 'fullScreen', 'destroyedItemUris', toProperty: 'model' + @delegatesMethods 'itemOpened', toProperty: 'model' @version: 4 @@ -74,9 +75,6 @@ class WorkspaceView extends View @panes.replaceWith(panes) @panes = panes - @destroyedItemUris = [] - @subscribe @model, 'pane-item-destroyed', @onPaneItemDestroyed - @updateTitle() @on 'focus', (e) => @handleFocus(e) @@ -358,17 +356,7 @@ class WorkspaceView extends View editorView.remove() for editorView in @getEditorViews() super - # Private: Adds the destroyed item's uri to the list of items to reopen. - onPaneItemDestroyed: (item) => - if uri = item.getUri?() - @destroyedItemUris.push(uri) - # Public: Reopens the last-closed item uri if it hasn't already been reopened. reopenItemSync: -> if uri = @destroyedItemUris.pop() @openSync(uri) - - # Private: Removes the item's uri from the list of potential items to reopen. - itemOpened: (item) -> - if uri = item.getUri?() - _.remove(@destroyedItemUris, uri) diff --git a/src/workspace.coffee b/src/workspace.coffee index 7b283b7d1..657f35d0e 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -1,3 +1,4 @@ +{remove} = require 'underscore-plus' {Model} = require 'theorist' Serializable = require 'serializable' PaneContainer = require './pane-container' @@ -10,6 +11,7 @@ class Workspace extends Model @properties paneContainer: -> new PaneContainer fullScreen: false + destroyedItemUris: -> [] constructor: -> super @@ -23,5 +25,12 @@ class Workspace extends Model paneContainer: @paneContainer.serialize() fullScreen: atom.isFullScreen() + # Private: Removes the item's uri from the list of potential items to reopen. + itemOpened: (item) -> + if uri = item.getUri?() + remove(@destroyedItemUris, uri) + + # Private: Adds the destroyed item's uri to the list of items to reopen. onPaneItemDestroyed: (item) => - @emit 'pane-item-destroyed', item + if uri = item.getUri?() + @destroyedItemUris.push(uri)