mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Move management of destroyedItemUris to Workspace model
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user