Derive PaneView::activeView from the model's activeItem

We're getting into some strange order-sensitive cases where we respond
to a change of the active item before the pane has a chance to reassign
the active view. Therefore it makes more sense to always just derive the
active view from the active item.
This commit is contained in:
Nathan Sobo
2014-01-13 21:27:56 -07:00
parent 1eb9c3d0d5
commit 7199cda549
2 changed files with 6 additions and 4 deletions

View File

@@ -52,7 +52,8 @@
"underscore-plus": "0.6.1",
"theorist": "~0.13.0",
"delegato": "~0.4.0",
"mixto": "~0.4.0"
"mixto": "~0.4.0",
"property-accessors": "~0.1.0"
},
"packageDependencies": {
"atom-dark-syntax": "0.10.0",

View File

@@ -1,6 +1,7 @@
{$, View} = require './space-pen-extensions'
Serializable = require 'serializable'
Delegator = require 'delegato'
PropertyAccessors = require 'property-accessors'
Pane = require './pane'
@@ -14,6 +15,7 @@ module.exports =
class PaneView extends View
Serializable.includeInto(this)
Delegator.includeInto(this)
PropertyAccessors.includeInto(this)
@version: 1
@@ -152,7 +154,6 @@ class PaneView extends View
view.show() if @attached
view.focus() if hasFocus
@activeView = view
@trigger 'pane:active-item-changed', [item]
onItemAdded: (item, index) =>
@@ -186,6 +187,7 @@ class PaneView extends View
# Private:
viewForItem: (item) ->
return unless item?
if item instanceof $
item
else if view = @viewsByItem.get(item)
@@ -197,8 +199,7 @@ class PaneView extends View
view
# Private:
viewForActiveItem: ->
@viewForItem(@activeItem)
@::accessor 'activeView', -> @viewForItem(@activeItem)
splitLeft: (items...) -> @model.splitLeft({items})._view