From 829bfa0a102fa96389c751e2ba83ba0047791d5b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 18 Feb 2013 16:37:13 -0700 Subject: [PATCH] Add `Pane.itemForPath` --- spec/app/pane-spec.coffee | 5 +++++ src/app/pane.coffee | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index e4a551906..e928bdd45 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -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 \ No newline at end of file diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 774654b76..006fd2d2a 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -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')