     @nearestPaneInDirection('right')?.focus()
 
   nearestPaneInDirection: (direction) ->
+    distance: (pointA, pointB) ->
+      x = pointB.x - pointA.x
+      y = pointB.y - pointA.y
+      Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
+
     pane = @getActivePane()
     box = @boundingBoxForPane(pane)
     panes = @getPanes()

    right: {x: boundingBox.right, y: boundingBox.top}
    top: {x: boundingBox.left, y: boundingBox.top}
    bottom: {x: boundingBox.left, y: boundingBox.bottom}

  distanceBetweenPoints: (pointA, pointB) ->
    x = pointB.x - pointA.x
    y = pointB.y - pointA.y
    Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

        boxA = @boundingBoxForPane(paneA)
        boxB = @boundingBoxForPane(paneB)
        switch direction
          when 'left' then @distance(box.left, boxA.right) - @distance(box.left, boxB.right)
          when 'right' then @distance(box.right, boxA.left) - @distance(box.right, boxB.left)
          when 'above' then @distance(box.top, boxA.bottom) - @distance(box.top, boxB.bottom)
          when 'below' then @distance(box.bottom, boxA.top) - @distance(box.bottom, boxB.top)

    panes[0]

