mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)
* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 * fix pipelines * fix strict-null-checks * add missing files
This commit is contained in:
@@ -33,13 +33,21 @@ export interface IWorkspaceProvider {
|
||||
*/
|
||||
readonly workspace: IWorkspace;
|
||||
|
||||
/**
|
||||
* Arbitrary payload from the `IWorkspaceProvider.open` call.
|
||||
*/
|
||||
readonly payload?: object;
|
||||
|
||||
/**
|
||||
* Asks to open a workspace in the current or a new window.
|
||||
*
|
||||
* @param workspace the workspace to open.
|
||||
* @param options wether to open inside the current window or a new window.
|
||||
* @param options optional options for the workspace to open.
|
||||
* - `reuse`: wether 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.
|
||||
*/
|
||||
open(workspace: IWorkspace, options?: { reuse?: boolean }): Promise<void>;
|
||||
open(workspace: IWorkspace, options?: { reuse?: boolean, payload?: object }): Promise<void>;
|
||||
}
|
||||
|
||||
export class BrowserHostService extends Disposable implements IHostService {
|
||||
@@ -66,23 +74,21 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
async open() { }
|
||||
};
|
||||
}
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
private _onDidChangeFocus: Event<boolean> | undefined;
|
||||
get onDidChangeFocus(): Event<boolean> {
|
||||
if (!this._onDidChangeFocus) {
|
||||
const focusTracker = this._register(trackFocus(window));
|
||||
this._onDidChangeFocus = Event.any(
|
||||
Event.map(focusTracker.onDidFocus, () => this.hasFocus),
|
||||
Event.map(focusTracker.onDidBlur, () => this.hasFocus)
|
||||
);
|
||||
}
|
||||
|
||||
// Track Focus on Window
|
||||
const focusTracker = this._register(trackFocus(window));
|
||||
this._onDidChangeFocus = Event.any(
|
||||
Event.map(focusTracker.onDidFocus, () => this.hasFocus),
|
||||
Event.map(focusTracker.onDidBlur, () => this.hasFocus)
|
||||
);
|
||||
return this._onDidChangeFocus;
|
||||
}
|
||||
|
||||
get onDidChangeFocus(): Event<boolean> { return this._onDidChangeFocus; }
|
||||
private _onDidChangeFocus: Event<boolean>;
|
||||
|
||||
get hasFocus(): boolean {
|
||||
return document.hasFocus();
|
||||
}
|
||||
@@ -138,7 +144,7 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
|
||||
private shouldReuse(options: IOpenWindowOptions = {}): boolean {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const openFolderInNewWindowConfig = (windowConfig && windowConfig.openFoldersInNewWindow) || 'default' /* default */;
|
||||
const openFolderInNewWindowConfig = windowConfig?.openFoldersInNewWindow || 'default' /* default */;
|
||||
|
||||
let openFolderInNewWindow = !!options.forceNewWindow && !options.forceReuseWindow;
|
||||
if (!options.forceNewWindow && !options.forceReuseWindow && (openFolderInNewWindowConfig === 'on' || openFolderInNewWindowConfig === 'off')) {
|
||||
@@ -149,7 +155,7 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
}
|
||||
|
||||
private async doOpenEmptyWindow(options?: IOpenEmptyWindowOptions): Promise<void> {
|
||||
this.workspaceProvider.open(undefined, { reuse: options && options.forceReuseWindow });
|
||||
this.workspaceProvider.open(undefined, { reuse: options?.forceReuseWindow });
|
||||
}
|
||||
|
||||
async toggleFullScreen(): Promise<void> {
|
||||
@@ -193,10 +199,6 @@ export class BrowserHostService extends Disposable implements IHostService {
|
||||
async reload(): Promise<void> {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
async closeWorkspace(): Promise<void> {
|
||||
return this.doOpenEmptyWindow({ forceReuseWindow: true });
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IHostService, BrowserHostService, true);
|
||||
|
||||
Reference in New Issue
Block a user