提交 039f15a0 编写于 作者: B Benjamin Pasero

💄

上级 c7fa31fc
...@@ -1602,3 +1602,9 @@ export class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> { ...@@ -1602,3 +1602,9 @@ export class ModifierKeyEmitter extends Emitter<IModifierKeyStatus> {
this._subscriptions.dispose(); this._subscriptions.dispose();
} }
} }
export function getCookieValue(name: string): string | undefined {
const match = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531
return match ? match.pop() : undefined;
}
...@@ -16,7 +16,6 @@ import { IOpener, IOpenerService, IValidator, IExternalUriResolver, OpenOptions, ...@@ -16,7 +16,6 @@ import { IOpener, IOpenerService, IValidator, IExternalUriResolver, OpenOptions,
import { EditorOpenContext } from 'vs/platform/editor/common/editor'; import { EditorOpenContext } from 'vs/platform/editor/common/editor';
import { ResourceMap } from 'vs/base/common/map'; import { ResourceMap } from 'vs/base/common/map';
class CommandOpener implements IOpener { class CommandOpener implements IOpener {
constructor(@ICommandService private readonly _commandService: ICommandService) { } constructor(@ICommandService private readonly _commandService: ICommandService) { }
...@@ -108,7 +107,7 @@ export class OpenerService implements IOpenerService { ...@@ -108,7 +107,7 @@ export class OpenerService implements IOpenerService {
) { ) {
// Default external opener is going through window.open() // Default external opener is going through window.open()
this._externalOpener = { this._externalOpener = {
openExternal: href => { openExternal: async href => {
// ensure to open HTTP/HTTPS links into new windows // ensure to open HTTP/HTTPS links into new windows
// to not trigger a navigation. Any other link is // to not trigger a navigation. Any other link is
// safe to be set as HREF to prevent a blank window // safe to be set as HREF to prevent a blank window
...@@ -118,11 +117,11 @@ export class OpenerService implements IOpenerService { ...@@ -118,11 +117,11 @@ export class OpenerService implements IOpenerService {
} else { } else {
window.location.href = href; window.location.href = href;
} }
return Promise.resolve(true); return true;
} }
}; };
// Default opener: maito, http(s), command, and catch-all-editors // Default opener: any external, maito, http(s), command, and catch-all-editors
this._openers.push({ this._openers.push({
open: async (target: URI | string, options?: OpenOptions) => { open: async (target: URI | string, options?: OpenOptions) => {
if (options?.openExternal || matchesScheme(target, Schemas.mailto) || matchesScheme(target, Schemas.http) || matchesScheme(target, Schemas.https)) { if (options?.openExternal || matchesScheme(target, Schemas.mailto) || matchesScheme(target, Schemas.http) || matchesScheme(target, Schemas.https)) {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { mark } from 'vs/base/common/performance'; import { mark } from 'vs/base/common/performance';
import { hash } from 'vs/base/common/hash'; import { hash } from 'vs/base/common/hash';
import { domContentLoaded, addDisposableListener, EventType, EventHelper, detectFullscreen, addDisposableThrottledListener } from 'vs/base/browser/dom'; import { domContentLoaded, addDisposableListener, EventType, EventHelper, detectFullscreen, addDisposableThrottledListener, getCookieValue } from 'vs/base/browser/dom';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILogService, ConsoleLogService, MultiplexLogService, getLogLevel } from 'vs/platform/log/common/log'; import { ILogService, ConsoleLogService, MultiplexLogService, getLogLevel } from 'vs/platform/log/common/log';
import { ConsoleLogInAutomationService } from 'vs/platform/log/browser/log'; import { ConsoleLogInAutomationService } from 'vs/platform/log/browser/log';
...@@ -142,9 +142,7 @@ class BrowserMain extends Disposable { ...@@ -142,9 +142,7 @@ class BrowserMain extends Disposable {
event.veto(true); // prevent data loss from pending storage update event.veto(true); // prevent data loss from pending storage update
} }
})); }));
this._register(workbench.onWillShutdown(() => { this._register(workbench.onWillShutdown(() => storageService.close()));
storageService.close();
}));
this._register(workbench.onShutdown(() => this.dispose())); this._register(workbench.onShutdown(() => this.dispose()));
// Fullscreen (Browser) // Fullscreen (Browser)
...@@ -181,9 +179,8 @@ class BrowserMain extends Disposable { ...@@ -181,9 +179,8 @@ class BrowserMain extends Disposable {
const logService = new BufferLogService(getLogLevel(environmentService)); const logService = new BufferLogService(getLogLevel(environmentService));
serviceCollection.set(ILogService, logService); serviceCollection.set(ILogService, logService);
const connectionToken = environmentService.options.connectionToken || this.getCookieValue('vscode-tkn');
// Remote // Remote
const connectionToken = environmentService.options.connectionToken || getCookieValue('vscode-tkn');
const remoteAuthorityResolverService = new RemoteAuthorityResolverService(connectionToken, this.configuration.resourceUriProvider); const remoteAuthorityResolverService = new RemoteAuthorityResolverService(connectionToken, this.configuration.resourceUriProvider);
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService); serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
...@@ -240,12 +237,14 @@ class BrowserMain extends Disposable { ...@@ -240,12 +237,14 @@ class BrowserMain extends Disposable {
if (await userDataInitializationService.requiresInitialization()) { if (await userDataInitializationService.requiresInitialization()) {
mark('willInitRequiredUserData'); mark('willInitRequiredUserData');
// Initialize required resources - settings & global state // Initialize required resources - settings & global state
await userDataInitializationService.initializeRequiredResources(); await userDataInitializationService.initializeRequiredResources();
// Important: Reload only local user configuration after initializing // Important: Reload only local user configuration after initializing
// Reloading complete configuraiton blocks workbench until remote configuration is loaded. // Reloading complete configuraiton blocks workbench until remote configuration is loaded.
await configurationService.reloadLocalUserConfiguration(); await configurationService.reloadLocalUserConfiguration();
mark('didInitRequiredUserData'); mark('didInitRequiredUserData');
} }
...@@ -370,12 +369,6 @@ class BrowserMain extends Disposable { ...@@ -370,12 +369,6 @@ class BrowserMain extends Disposable {
return { id: 'empty-window' }; return { id: 'empty-window' };
} }
private getCookieValue(name: string): string | undefined {
const match = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531
return match ? match.pop() : undefined;
}
} }
export function main(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise<IWorkbench> { export function main(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise<IWorkbench> {
......
...@@ -344,8 +344,11 @@ class DesktopMain extends Disposable { ...@@ -344,8 +344,11 @@ class DesktopMain extends Disposable {
const folder = folderUri.scheme === Schemas.file const folder = folderUri.scheme === Schemas.file
? URI.file(sanitizeFilePath(folderUri.fsPath, process.env['VSCODE_CWD'] || process.cwd())) // For local: ensure path is absolute ? URI.file(sanitizeFilePath(folderUri.fsPath, process.env['VSCODE_CWD'] || process.cwd())) // For local: ensure path is absolute
: folderUri; : folderUri;
const id = await this.createHash(folderUri);
return { id, folder }; return {
id: await this.createHash(folderUri),
folder
};
} catch (error) { } catch (error) {
onUnexpectedError(error); onUnexpectedError(error);
} }
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls'; import { localize } from 'vs/nls';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import * as errors from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { equals } from 'vs/base/common/objects'; import { equals } from 'vs/base/common/objects';
import * as DOM from 'vs/base/browser/dom'; import { EventType, EventHelper, addDisposableListener } from 'vs/base/browser/dom';
import { IAction, Separator } from 'vs/base/common/actions'; import { IAction, Separator } from 'vs/base/common/actions';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor'; import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor';
...@@ -126,9 +126,9 @@ export class NativeWindow extends Disposable { ...@@ -126,9 +126,9 @@ export class NativeWindow extends Disposable {
this._register(this.editorService.onDidActiveEditorChange(() => this.updateTouchbarMenu())); this._register(this.editorService.onDidActiveEditorChange(() => this.updateTouchbarMenu()));
// prevent opening a real URL inside the shell // prevent opening a real URL inside the shell
[DOM.EventType.DRAG_OVER, DOM.EventType.DROP].forEach(event => { [EventType.DRAG_OVER, EventType.DROP].forEach(event => {
window.document.body.addEventListener(event, (e: DragEvent) => { window.document.body.addEventListener(event, (e: DragEvent) => {
DOM.EventHelper.stop(e); EventHelper.stop(e);
}); });
}); });
...@@ -173,7 +173,7 @@ export class NativeWindow extends Disposable { ...@@ -173,7 +173,7 @@ export class NativeWindow extends Disposable {
// Error reporting from main // Error reporting from main
ipcRenderer.on('vscode:reportError', (event: unknown, error: string) => { ipcRenderer.on('vscode:reportError', (event: unknown, error: string) => {
if (error) { if (error) {
errors.onUnexpectedError(JSON.parse(error)); onUnexpectedError(JSON.parse(error));
} }
}); });
...@@ -188,13 +188,13 @@ export class NativeWindow extends Disposable { ...@@ -188,13 +188,13 @@ export class NativeWindow extends Disposable {
// Shell Environment Issue Notifications // Shell Environment Issue Notifications
const choices: IPromptChoice[] = [{ const choices: IPromptChoice[] = [{
label: nls.localize('learnMode', "Learn More"), label: localize('learnMode', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667') run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}]; }];
ipcRenderer.on('vscode:showShellEnvSlowWarning', () => this.notificationService.prompt( ipcRenderer.on('vscode:showShellEnvSlowWarning', () => this.notificationService.prompt(
Severity.Warning, Severity.Warning,
nls.localize('shellEnvSlowWarning', "Resolving your shell environment is taking very long. Please review your shell configuration."), localize('shellEnvSlowWarning', "Resolving your shell environment is taking very long. Please review your shell configuration."),
choices, choices,
{ {
sticky: true, sticky: true,
...@@ -204,7 +204,7 @@ export class NativeWindow extends Disposable { ...@@ -204,7 +204,7 @@ export class NativeWindow extends Disposable {
ipcRenderer.on('vscode:showShellEnvTimeoutError', () => this.notificationService.prompt( ipcRenderer.on('vscode:showShellEnvTimeoutError', () => this.notificationService.prompt(
Severity.Error, Severity.Error,
nls.localize('shellEnvTimeoutError', "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration."), localize('shellEnvTimeoutError', "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration."),
choices choices
)); ));
...@@ -222,20 +222,20 @@ export class NativeWindow extends Disposable { ...@@ -222,20 +222,20 @@ export class NativeWindow extends Disposable {
// Proxy Login Dialog // Proxy Login Dialog
ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, payload: { authInfo: AuthInfo, username?: string, password?: string, replyChannel: string }) => { ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, payload: { authInfo: AuthInfo, username?: string, password?: string, replyChannel: string }) => {
const rememberCredentials = this.storageService.getBoolean(NativeWindow.REMEMBER_PROXY_CREDENTIALS_KEY, StorageScope.GLOBAL); const rememberCredentials = this.storageService.getBoolean(NativeWindow.REMEMBER_PROXY_CREDENTIALS_KEY, StorageScope.GLOBAL);
const result = await this.dialogService.input(Severity.Warning, nls.localize('proxyAuthRequired', "Proxy Authentication Required"), const result = await this.dialogService.input(Severity.Warning, localize('proxyAuthRequired', "Proxy Authentication Required"),
[ [
nls.localize({ key: 'loginButton', comment: ['&& denotes a mnemonic'] }, "&&Log In"), localize({ key: 'loginButton', comment: ['&& denotes a mnemonic'] }, "&&Log In"),
nls.localize({ key: 'cancelButton', comment: ['&& denotes a mnemonic'] }, "&&Cancel") localize({ key: 'cancelButton', comment: ['&& denotes a mnemonic'] }, "&&Cancel")
], ],
[ [
{ placeholder: nls.localize('username', "Username"), value: payload.username }, { placeholder: localize('username', "Username"), value: payload.username },
{ placeholder: nls.localize('password', "Password"), type: 'password', value: payload.password } { placeholder: localize('password', "Password"), type: 'password', value: payload.password }
], ],
{ {
cancelId: 1, cancelId: 1,
detail: nls.localize('proxyDetail', "The proxy {0} requires a username and password.", `${payload.authInfo.host}:${payload.authInfo.port}`), detail: localize('proxyDetail', "The proxy {0} requires a username and password.", `${payload.authInfo.host}:${payload.authInfo.port}`),
checkbox: { checkbox: {
label: nls.localize('rememberCredentials', "Remember my credentials"), label: localize('rememberCredentials', "Remember my credentials"),
checked: rememberCredentials checked: rememberCredentials
} }
}); });
...@@ -303,8 +303,8 @@ export class NativeWindow extends Disposable { ...@@ -303,8 +303,8 @@ export class NativeWindow extends Disposable {
if (isMacintosh && getTitleBarStyle(this.configurationService) === 'custom') { if (isMacintosh && getTitleBarStyle(this.configurationService) === 'custom') {
const titlePart = assertIsDefined(this.layoutService.getContainer(Parts.TITLEBAR_PART)); const titlePart = assertIsDefined(this.layoutService.getContainer(Parts.TITLEBAR_PART));
this._register(DOM.addDisposableListener(titlePart, DOM.EventType.DBLCLICK, e => { this._register(addDisposableListener(titlePart, EventType.DBLCLICK, e => {
DOM.EventHelper.stop(e); EventHelper.stop(e);
this.nativeHostService.handleTitleDoubleClick(); this.nativeHostService.handleTitleDoubleClick();
})); }));
...@@ -331,9 +331,7 @@ export class NativeWindow extends Disposable { ...@@ -331,9 +331,7 @@ export class NativeWindow extends Disposable {
this.onDidChangeMaximized(this.environmentService.configuration.maximized ?? false); this.onDidChangeMaximized(this.environmentService.configuration.maximized ?? false);
// Detect panel position to determine minimum width // Detect panel position to determine minimum width
this._register(this.layoutService.onPanelPositionChange(pos => { this._register(this.layoutService.onPanelPositionChange(pos => this.onDidPanelPositionChange(positionFromString(pos))));
this.onDidPanelPositionChange(positionFromString(pos));
}));
this.onDidPanelPositionChange(this.layoutService.getPanelPosition()); this.onDidPanelPositionChange(this.layoutService.getPanelPosition());
} }
...@@ -350,18 +348,19 @@ export class NativeWindow extends Disposable { ...@@ -350,18 +348,19 @@ export class NativeWindow extends Disposable {
} }
private getWindowMinimumWidth(panelPosition: Position = this.layoutService.getPanelPosition()): number { private getWindowMinimumWidth(panelPosition: Position = this.layoutService.getPanelPosition()): number {
// if panel is on the side, then return the larger minwidth // if panel is on the side, then return the larger minwidth
const panelOnSide = panelPosition === Position.LEFT || panelPosition === Position.RIGHT; const panelOnSide = panelPosition === Position.LEFT || panelPosition === Position.RIGHT;
if (panelOnSide) { if (panelOnSide) {
return WindowMinimumSize.WIDTH_WITH_VERTICAL_PANEL; return WindowMinimumSize.WIDTH_WITH_VERTICAL_PANEL;
} }
else {
return WindowMinimumSize.WIDTH; return WindowMinimumSize.WIDTH;
}
} }
private onDidPanelPositionChange(pos: Position): void { private onDidPanelPositionChange(pos: Position): void {
const minWidth = this.getWindowMinimumWidth(pos); const minWidth = this.getWindowMinimumWidth(pos);
this.nativeHostService.setMinimumSize(minWidth, undefined); this.nativeHostService.setMinimumSize(minWidth, undefined);
} }
...@@ -470,7 +469,7 @@ export class NativeWindow extends Disposable { ...@@ -470,7 +469,7 @@ export class NativeWindow extends Disposable {
// Show warning message (unix only) // Show warning message (unix only)
if (isAdmin && !isWindows) { if (isAdmin && !isWindows) {
this.notificationService.warn(nls.localize('runningAsRoot', "It is not recommended to run {0} as root user.", this.productService.nameShort)); this.notificationService.warn(localize('runningAsRoot', "It is not recommended to run {0} as root user.", this.productService.nameShort));
} }
}); });
...@@ -704,7 +703,7 @@ class NativeMenubarControl extends MenubarControl { ...@@ -704,7 +703,7 @@ class NativeMenubarControl extends MenubarControl {
if (isMacintosh) { if (isMacintosh) {
this.menus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService)); this.menus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService));
this.topLevelTitles['Preferences'] = nls.localize('mPreferences', "Preferences"); this.topLevelTitles['Preferences'] = localize('mPreferences', "Preferences");
} }
for (const topLevelMenuName of Object.keys(this.topLevelTitles)) { for (const topLevelMenuName of Object.keys(this.topLevelTitles)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册