allow null for remoteAuthority in IBaseOpenWindowsOptions to force local window

This commit is contained in:
Martin Aeschlimann 2021-03-09 16:05:48 +01:00
parent 3c96cb6254
commit b8a320867e
No known key found for this signature in database
GPG key ID: 2609A01E695523E3
8 changed files with 9 additions and 9 deletions

View file

@ -302,7 +302,7 @@ function getActions(): ActionItem[] {
actions.push({
title: 'Close Remote',
execute: async () => {
await vscode.commands.executeCommand('vscode.newWindow', { reuseWindow: true });
await vscode.commands.executeCommand('vscode.newWindow', { reuseWindow: true, remoteAuthority: null });
}
});
}

View file

@ -162,7 +162,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
gotoLineMode: options.gotoLineMode,
noRecentEntry: options.noRecentEntry,
waitMarkerFileURI: options.waitMarkerFileURI,
remoteAuthority: options.remoteAuthority
remoteAuthority: options.remoteAuthority || undefined
});
}
}

View file

@ -19,7 +19,7 @@ export const WindowMinimumSize = {
export interface IBaseOpenWindowsOptions {
readonly forceReuseWindow?: boolean;
readonly remoteAuthority?: string; /* used when no inputs are provided or inputs are neither file nor vscode-remote */
readonly remoteAuthority?: string | null; /* used when no inputs are provided or inputs are neither file nor vscode-remote. Null forces a local window */
}
export interface IOpenWindowOptions extends IBaseOpenWindowsOptions {

View file

@ -160,7 +160,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
openEmptyWindow(openConfig: IOpenEmptyConfiguration, options?: IOpenEmptyWindowOptions): ICodeWindow[] {
let cli = this.environmentMainService.args;
const remoteAuthority = options?.remoteAuthority;
const remoteAuthority = options?.remoteAuthority || undefined;
const forceEmpty = true;
const forceReuseWindow = options?.forceReuseWindow;
const forceNewWindow = !forceReuseWindow;

View file

@ -32,7 +32,7 @@ function adjustHandler(handler: (executor: ICommandsExecutor, ...args: any[]) =>
interface INewWindowAPICommandOptions {
reuseWindow?: boolean;
remoteAuthority?: string;
remoteAuthority?: string | null; /* allow null to force a local window */
}
export class NewWindowAPICommand {

View file

@ -343,7 +343,7 @@ export class NewWindowAction extends Action {
}
run(): Promise<void> {
return this.hostService.openWindow();
return this.hostService.openWindow({ remoteAuthority: null });
}
}

View file

@ -98,7 +98,7 @@ export class RemoteStatusIndicator extends Disposable implements IWorkbenchContr
f1: true
});
}
run = () => that.remoteAuthority && that.hostService.openWindow({ forceReuseWindow: true, remoteAuthority: undefined });
run = () => that.remoteAuthority && that.hostService.openWindow({ forceReuseWindow: true, remoteAuthority: null });
});
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {

View file

@ -66,8 +66,8 @@ export class NativeHostService extends Disposable implements IHostService {
if (!!remoteAuthority) {
toOpen.forEach(openable => openable.label = openable.label || this.getRecentLabel(openable));
if (!options || !options.hasOwnProperty('remoteAuthority')) {
// pass the remoteAuthority of the window the request came from.
if (options?.remoteAuthority === undefined) {
// set the remoteAuthority of the window the request came from.
// It will be used when the input is neither file nor vscode-remote.
options = options ? { ...options, remoteAuthority } : { remoteAuthority };
}