diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 9c6b987b0..404b405ac 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -127,6 +127,22 @@ describe "Workspace", -> expect(pane1.items).toEqual [editor] expect(pane2.items).toEqual [] + describe "when a pane axis is to the left of the current pane", -> + it "opens the new item in the current pane", -> + editor = null + pane1 = workspace.activePane + pane2 = pane1.splitLeft() + pane3 = pane2.splitDown() + pane1.activate() + expect(workspace.activePane).toBe pane1 + + waitsForPromise -> + workspace.open('a', split: 'left').then (o) -> editor = o + + runs -> + expect(workspace.activePane).toBe pane1 + expect(pane1.items).toEqual [editor] + describe "when the 'split' option is 'right'", -> it "opens the editor in the rightmost pane of the current pane axis", -> editor = null diff --git a/src/pane.coffee b/src/pane.coffee index 1fa3a9cc7..e0c579257 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -339,15 +339,19 @@ class Pane extends Model newPane.activate() newPane - # If the parent is a horizontal axis, returns its first child; - # otherwise this pane. + # If the parent is a horizontal axis, returns its first child if it is a pane; + # otherwise returns this pane. findLeftmostSibling: -> if @parent.orientation is 'horizontal' - @parent.children[0] + [leftmostSibling] = @parent.children + if leftmostSibling instanceof PaneAxis + this + else + leftmostSibling else this - # If the parent is a horizontal axis, returns its last child; + # If the parent is a horizontal axis, returns its last child if it is a pane; # otherwise returns a new pane created by splitting this pane rightward. findOrCreateRightmostSibling: -> if @parent.orientation is 'horizontal'