mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Add "location" param to open()
This commit is contained in:
parent
d9e1fcc70b
commit
52606171bf
@ -126,22 +126,21 @@ describe('Workspace', () => {
|
||||
})
|
||||
|
||||
it('constructs the view with the same panes', () => {
|
||||
const getRightDockActivePane = () => atom.workspace.getRightDock().getActivePane()
|
||||
const pane1 = atom.workspace.getRightDock().getActivePane()
|
||||
const pane2 = pane1.splitRight({copyActiveItem: true})
|
||||
const pane3 = pane2.splitRight({copyActiveItem: true})
|
||||
let pane4 = null
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open(null, {pane: getRightDockActivePane()}).then(editor => editor.setText('An untitled editor.'))
|
||||
atom.workspace.open(null, {location: 'right'}).then(editor => editor.setText('An untitled editor.'))
|
||||
)
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open('b', {pane: getRightDockActivePane()}).then(editor => pane2.activateItem(editor.copy()))
|
||||
atom.workspace.open('b', {location: 'right'}).then(editor => pane2.activateItem(editor.copy()))
|
||||
)
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open('../sample.js', {pane: getRightDockActivePane()}).then(editor => pane3.activateItem(editor))
|
||||
atom.workspace.open('../sample.js', {location: 'right'}).then(editor => pane3.activateItem(editor))
|
||||
)
|
||||
|
||||
runs(() => {
|
||||
@ -150,7 +149,7 @@ describe('Workspace', () => {
|
||||
})
|
||||
|
||||
waitsForPromise(() =>
|
||||
atom.workspace.open('../sample.txt', {pane: getRightDockActivePane()}).then(editor => pane4.activateItem(editor))
|
||||
atom.workspace.open('../sample.txt', {location: 'right'}).then(editor => pane4.activateItem(editor))
|
||||
)
|
||||
|
||||
runs(() => {
|
||||
|
@ -617,6 +617,12 @@ module.exports = class Workspace extends Model {
|
||||
// activate an existing item for the given URI on any pane.
|
||||
// If `false`, only the active pane will be searched for
|
||||
// an existing item for the same URI. Defaults to `false`.
|
||||
// * `location` (optional) A {String} containing the name of the location
|
||||
// in which this item should be opened (one of "left", "right", "bottom",
|
||||
// or "center"). If omitted, Atom will fall back to the last location in
|
||||
// which a user has placed an item with the same URI or, if this is a new
|
||||
// URI, the default location specified by the item. NOTE: This option
|
||||
// should almost always be omitted to honor user preference.
|
||||
//
|
||||
// Returns a {Promise} that resolves to the {TextEditor} for the file URI.
|
||||
open (uri_, options = {}) {
|
||||
@ -767,7 +773,7 @@ module.exports = class Workspace extends Model {
|
||||
}
|
||||
|
||||
async openItem (item, options = {}) {
|
||||
let {pane, split} = options
|
||||
let {pane, split, location} = options
|
||||
|
||||
if (item == null) return undefined
|
||||
if (pane != null && pane.isDestroyed()) return item
|
||||
@ -779,14 +785,12 @@ module.exports = class Workspace extends Model {
|
||||
paneContainer = this.getPaneContainers().find(container => container.getPanes().includes(pane))
|
||||
}
|
||||
|
||||
// Determine which location to use, unless a split was provided. In that case, make sure it goes
|
||||
// in the center location (legacy behavior)
|
||||
let location
|
||||
if (paneContainer == null && pane == null && split == null && uri != null) {
|
||||
location = await this.itemLocationStore.load(uri)
|
||||
}
|
||||
|
||||
if (paneContainer == null) {
|
||||
// Determine which location to use, unless a split was provided. In that case, make sure it goes
|
||||
// in the center location (legacy behavior)
|
||||
if (location == null && pane == null && split == null && uri != null) {
|
||||
location = await this.itemLocationStore.load(uri)
|
||||
}
|
||||
if (location == null && typeof item.getDefaultLocation === 'function') {
|
||||
location = item.getDefaultLocation()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user