Add Pane.itemForPath

This commit is contained in:
Nathan Sobo 2013-02-18 16:37:13 -07:00 committed by probablycorey
parent c6729e9df1
commit 829bfa0a10
2 changed files with 8 additions and 1 deletions

View File

@ -101,3 +101,8 @@ describe "Pane", ->
pane.remove()
expect(editSession1.destroyed).toBeTruthy()
expect(editSession2.destroyed).toBeTruthy()
describe ".itemForPath(path)", ->
it "returns the item for which a call to .getPath() returns the given path", ->
expect(pane.itemForPath(editSession1.getPath())).toBe editSession1
expect(pane.itemForPath(editSession2.getPath())).toBe editSession2

View File

@ -67,6 +67,9 @@ class Pane extends View
item.destroy?()
@cleanupItemView(item)
itemForPath: (path) ->
_.detect @items, (item) -> item.getPath?() is path
cleanupItemView: (item) ->
if item instanceof $
item.remove()
@ -101,7 +104,6 @@ class Pane extends View
verticalGridUnits: -> 1
splitUp: (view) ->
@split(view, 'column', 'before')