Handle the 'split' option directly in Workspace::openSingletonSync

This commit is contained in:
Nathan Sobo
2014-01-21 13:59:50 -07:00
parent 5e83dee493
commit 726b546004
2 changed files with 31 additions and 8 deletions

View File

@@ -115,15 +115,22 @@ class Workspace extends Model
openSingletonSync: (uri, {changeFocus, initialLine, split}={}) ->
changeFocus ?= true
uri = atom.project.relativize(uri)
pane = @paneContainer.paneForUri(uri)
if pane
paneItem = pane.itemForUri(uri)
pane.activateItem(paneItem)
pane.activate() if changeFocus
paneItem
if pane = @paneContainer.paneForUri(uri)
editor = pane.itemForUri(uri)
else
@openSync(uri, {changeFocus, initialLine, split})
pane = switch split
when 'left'
@activePane.findLeftmostSibling()
when 'right'
@activePane.findOrCreateRightmostSibling()
else
@activePane
editor = atom.project.openSync(uri, {initialLine})
pane.activateItem(editor)
pane.activate() if changeFocus
editor
# Public: Reopens the last-closed item uri if it hasn't already been reopened.
reopenItemSync: ->