mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 02:32:35 -05:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -17,6 +17,7 @@ import { trackFocus } from 'vs/base/browser/dom';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { mapToSerializable } from 'vs/base/common/map';
|
||||
|
||||
/**
|
||||
* A workspace to open in the workbench can either be:
|
||||
@@ -43,9 +44,10 @@ export interface IWorkspaceProvider {
|
||||
*
|
||||
* @param workspace the workspace to open.
|
||||
* @param options optional options for the workspace to open.
|
||||
* - `reuse`: wether to open inside the current window or a new window
|
||||
* - `reuse`: whether to open inside the current window or a new window
|
||||
* - `payload`: arbitrary payload that should be made available
|
||||
* to the opening window via the `IWorkspaceProvider.payload` property.
|
||||
* @param payload optional payload to send to the workspace to open.
|
||||
*/
|
||||
open(workspace: IWorkspace, options?: { reuse?: boolean, payload?: object }): Promise<void>;
|
||||
}
|
||||
@@ -114,18 +116,30 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
|
||||
// Folder
|
||||
if (isFolderToOpen(openable)) {
|
||||
this.workspaceProvider.open({ folderUri: openable.folderUri }, { reuse: this.shouldReuse(options) });
|
||||
this.workspaceProvider.open({ folderUri: openable.folderUri }, { reuse: this.shouldReuse(options, false /* no file */) });
|
||||
}
|
||||
|
||||
// Workspace
|
||||
else if (isWorkspaceToOpen(openable)) {
|
||||
this.workspaceProvider.open({ workspaceUri: openable.workspaceUri }, { reuse: this.shouldReuse(options) });
|
||||
this.workspaceProvider.open({ workspaceUri: openable.workspaceUri }, { reuse: this.shouldReuse(options, false /* no file */) });
|
||||
}
|
||||
|
||||
// File: open via editor service in current window
|
||||
// File
|
||||
else if (isFileToOpen(openable)) {
|
||||
const inputs: IResourceEditor[] = await pathsToEditors([openable], this.fileService);
|
||||
this.editorService.openEditors(inputs);
|
||||
|
||||
// Same Window: open via editor service in current window
|
||||
if (this.shouldReuse(options, true /* file */)) {
|
||||
const inputs: IResourceEditor[] = await pathsToEditors([openable], this.fileService);
|
||||
this.editorService.openEditors(inputs);
|
||||
}
|
||||
|
||||
// New Window: open into empty window
|
||||
else {
|
||||
const environment = new Map<string, string>();
|
||||
environment.set('openFile', openable.fileUri.toString());
|
||||
|
||||
this.workspaceProvider.open(undefined, { payload: mapToSerializable(environment) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,16 +156,16 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
return this.labelService.getUriLabel(openable.fileUri);
|
||||
}
|
||||
|
||||
private shouldReuse(options: IOpenWindowOptions = {}): boolean {
|
||||
private shouldReuse(options: IOpenWindowOptions = {}, isFile: boolean): boolean {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const openFolderInNewWindowConfig = windowConfig?.openFoldersInNewWindow || 'default' /* default */;
|
||||
const openInNewWindowConfig = isFile ? (windowConfig?.openFilesInNewWindow || 'off' /* default */) : (windowConfig?.openFoldersInNewWindow || 'default' /* default */);
|
||||
|
||||
let openFolderInNewWindow = (options.preferNewWindow || !!options.forceNewWindow) && !options.forceReuseWindow;
|
||||
if (!options.forceNewWindow && !options.forceReuseWindow && (openFolderInNewWindowConfig === 'on' || openFolderInNewWindowConfig === 'off')) {
|
||||
openFolderInNewWindow = (openFolderInNewWindowConfig === 'on');
|
||||
let openInNewWindow = (options.preferNewWindow || !!options.forceNewWindow) && !options.forceReuseWindow;
|
||||
if (!options.forceNewWindow && !options.forceReuseWindow && (openInNewWindowConfig === 'on' || openInNewWindowConfig === 'off')) {
|
||||
openInNewWindow = (openInNewWindowConfig === 'on');
|
||||
}
|
||||
|
||||
return !openFolderInNewWindow;
|
||||
return !openInNewWindow;
|
||||
}
|
||||
|
||||
private async doOpenEmptyWindow(options?: IOpenEmptyWindowOptions): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user