mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Make Pane maintain a currentView pointer based on its current item
This commit is contained in:
committed by
probablycorey
parent
d310fb366f
commit
ad62f896bc
@@ -41,7 +41,8 @@ describe "Pane", ->
|
||||
describe "when no view has yet been appended for that item", ->
|
||||
it "appends and shows a view to display the item based on its `.getViewClass` method", ->
|
||||
pane.showItem(editSession1)
|
||||
editor = pane.itemViews.find('.editor').view()
|
||||
editor = pane.currentView
|
||||
expect(editor.css('display')).toBe ''
|
||||
expect(editor.activeEditSession).toBe editSession1
|
||||
|
||||
describe "when a valid view has already been appended for another item", ->
|
||||
@@ -49,7 +50,7 @@ describe "Pane", ->
|
||||
pane.showItem(editSession1)
|
||||
pane.showItem(editSession2)
|
||||
expect(pane.itemViews.find('.editor').length).toBe 1
|
||||
editor = pane.itemViews.find('.editor').view()
|
||||
editor = pane.currentView
|
||||
expect(editor.css('display')).toBe ''
|
||||
expect(editor.activeEditSession).toBe editSession2
|
||||
|
||||
@@ -58,6 +59,7 @@ describe "Pane", ->
|
||||
expect(pane.itemViews.find('#view-2')).not.toExist()
|
||||
pane.showItem(view2)
|
||||
expect(pane.itemViews.find('#view-2')).toExist()
|
||||
expect(pane.currentView).toBe view2
|
||||
|
||||
describe ".removeItem(item)", ->
|
||||
it "removes the item from the items list and shows the next item if it was showing", ->
|
||||
|
||||
@@ -58,10 +58,10 @@ class Pane extends View
|
||||
@addItem(item)
|
||||
@itemViews.children().hide()
|
||||
view = @viewForItem(item)
|
||||
unless view.parent().is(@itemViews)
|
||||
@itemViews.append(view)
|
||||
@itemViews.append(view) unless view.parent().is(@itemViews)
|
||||
@currentItem = item
|
||||
view.show()
|
||||
@currentView = view
|
||||
@currentView.show()
|
||||
|
||||
addItem: (item) ->
|
||||
return if _.include(@items, item)
|
||||
|
||||
Reference in New Issue
Block a user