mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add openSingletonSync() to rootView
This commit is contained in:
@@ -161,6 +161,12 @@ class PaneContainer extends View
|
||||
getActiveView: ->
|
||||
@getActivePane()?.activeView
|
||||
|
||||
paneForUri: (uri) ->
|
||||
for pane in @getPanes()
|
||||
view = pane.itemForUri(uri)
|
||||
return pane if view?
|
||||
null
|
||||
|
||||
adjustPaneDimensions: ->
|
||||
if root = @getRoot()
|
||||
root.css(width: '100%', height: '100%', top: 0, left: 0)
|
||||
|
||||
@@ -194,23 +194,44 @@ class RootView extends View
|
||||
editSession
|
||||
|
||||
# Private: Only used in specs
|
||||
openSync: (filePath, options = {}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
initialLine = options.initialLine
|
||||
filePath = project.relativize(filePath)
|
||||
if activePane = @getActivePane()
|
||||
if filePath
|
||||
editSession = activePane.itemForUri(filePath) ? project.openSync(filePath, {initialLine})
|
||||
else
|
||||
editSession = project.openSync()
|
||||
activePane.showItem(editSession)
|
||||
else
|
||||
editSession = project.openSync(filePath, {initialLine})
|
||||
activePane = new Pane(editSession)
|
||||
@panes.setRoot(activePane)
|
||||
openSync: (uri, {changeFocus, initialLine, pane, split}={}) ->
|
||||
changeFocus ?= true
|
||||
pane ?= @getActivePane()
|
||||
uri = project.relativize(uri)
|
||||
|
||||
activePane.focus() if changeFocus
|
||||
editSession
|
||||
if pane
|
||||
if uri
|
||||
paneItem = pane.itemForUri(uri) ? project.openSync(uri, {initialLine})
|
||||
else
|
||||
paneItem = project.openSync()
|
||||
|
||||
if split
|
||||
panes = @getPanes()
|
||||
if panes.length == 1
|
||||
pane = panes[0].splitRight()
|
||||
else
|
||||
pane = _.last(panes)
|
||||
|
||||
pane.showItem(paneItem)
|
||||
else
|
||||
paneItem = project.openSync(uri, {initialLine})
|
||||
pane = new Pane(paneItem)
|
||||
@panes.setRoot(pane)
|
||||
|
||||
pane.focus() if changeFocus
|
||||
paneItem
|
||||
|
||||
openSingletonSync: (uri, {split}={}) ->
|
||||
uri = project.relativize(uri)
|
||||
pane = @panes.paneForUri(uri)
|
||||
|
||||
if pane
|
||||
paneItem = pane.itemForUri(uri)
|
||||
pane.showItem(paneItem)
|
||||
pane.focus()
|
||||
paneItem
|
||||
else
|
||||
@openSync(uri, {split})
|
||||
|
||||
# Public: Updates the application's title, based on whichever file is open.
|
||||
updateTitle: ->
|
||||
|
||||
Reference in New Issue
Block a user