Merge from vscode 91e99652cd5fcfc072387c64e151b435e39e8dcf (#6962)

This commit is contained in:
Anthony Dresser
2019-08-26 15:58:42 -07:00
committed by GitHub
parent edf470c8fa
commit 507bae90b7
103 changed files with 1743 additions and 1543 deletions

View File

@@ -14,14 +14,18 @@ import { attachDialogStyler } from 'vs/platform/theme/common/styler';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { EventHelper } from 'vs/base/browser/dom';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
export class DialogService implements IDialogService {
_serviceBrand: any;
private allowableCommands = ['copy', 'cut'];
constructor(
@ILogService private readonly logService: ILogService,
@ILayoutService private readonly layoutService: ILayoutService,
@IThemeService private readonly themeService: IThemeService
@IThemeService private readonly themeService: IThemeService,
@IKeybindingService private readonly keybindingService: IKeybindingService
) { }
async confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
@@ -50,7 +54,12 @@ export class DialogService implements IDialogService {
cancelId: 1,
type: confirmation.type,
keyEventProcessor: (event: StandardKeyboardEvent) => {
EventHelper.stop(event, true);
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
if (resolved && resolved.commandId) {
if (this.allowableCommands.indexOf(resolved.commandId) === -1) {
EventHelper.stop(event, true);
}
}
},
checkboxChecked: confirmation.checkbox ? confirmation.checkbox.checked : undefined,
checkboxLabel: confirmation.checkbox ? confirmation.checkbox.label : undefined
@@ -82,7 +91,12 @@ export class DialogService implements IDialogService {
cancelId: options ? options.cancelId : undefined,
type: this.getDialogType(severity),
keyEventProcessor: (event: StandardKeyboardEvent) => {
EventHelper.stop(event, true);
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
if (resolved && resolved.commandId) {
if (this.allowableCommands.indexOf(resolved.commandId) === -1) {
EventHelper.stop(event, true);
}
}
}
});

View File

@@ -79,14 +79,41 @@ export interface IResourceInput extends IBaseResourceInput {
readonly mode?: string;
}
export enum EditorActivation {
/**
* Activate the editor after it opened.
*/
ACTIVATE,
/**
* Preserve the current active editor.
*
* Note: will only work in combination with the
* `preserveFocus: true` option.
*/
PRESERVE
}
export interface IEditorOptions {
/**
* Tells the editor to not receive keyboard focus when the editor is being opened. By default,
* the editor will receive keyboard focus on open.
* Tells the editor to not receive keyboard focus when the editor is being opened.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
readonly preserveFocus?: boolean;
/**
* This option is only relevant if an editor is opened into a group that is not active
* already and allows to control if the inactive group should become active or not.
*
* By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified.
*/
readonly activation?: EditorActivation;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
@@ -123,7 +150,10 @@ export interface IEditorOptions {
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background.
* in the background without loading its contents.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
readonly inactive?: boolean;

View File

@@ -148,24 +148,15 @@ export interface IEnvironmentService {
extensionTestsLocationURI?: URI;
debugExtensionHost: IExtensionHostDebugParams;
debugSearch: IDebugParams;
logExtensionHostCommunication: boolean;
isBuilt: boolean;
wait: boolean;
status: boolean;
// logging
log?: string;
logsPath: string;
verbose: boolean;
skipGettingStarted: boolean | undefined;
skipReleaseNotes: boolean | undefined;
skipAddToRecentlyOpened: boolean;
mainIPCHandle: string;
sharedIPCHandle: string;
@@ -178,9 +169,5 @@ export interface IEnvironmentService {
driverHandle?: string;
driverVerbose: boolean;
webviewEndpoint?: string;
readonly webviewResourceRoot: string;
readonly webviewCspSource: string;
readonly galleryMachineIdResource?: URI;
galleryMachineIdResource?: URI;
}

View File

@@ -236,26 +236,15 @@ export class EnvironmentService implements IEnvironmentService {
return false;
}
get skipGettingStarted(): boolean { return !!this._args['skip-getting-started']; }
get skipReleaseNotes(): boolean { return !!this._args['skip-release-notes']; }
get skipAddToRecentlyOpened(): boolean { return !!this._args['skip-add-to-recently-opened']; }
@memoize
get debugExtensionHost(): IExtensionHostDebugParams { return parseExtensionHostPort(this._args, this.isBuilt); }
@memoize
get debugSearch(): IDebugParams { return parseSearchPort(this._args, this.isBuilt); }
get isBuilt(): boolean { return !process.env['VSCODE_DEV']; }
get verbose(): boolean { return !!this._args.verbose; }
get log(): string | undefined { return this._args.log; }
get wait(): boolean { return !!this._args.wait; }
get logExtensionHostCommunication(): boolean { return !!this._args.logExtensionHostCommunication; }
get status(): boolean { return !!this._args.status; }
@memoize
@@ -276,9 +265,6 @@ export class EnvironmentService implements IEnvironmentService {
get driverHandle(): string | undefined { return this._args['driver']; }
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
readonly webviewResourceRoot = 'vscode-resource:{{resource}}';
readonly webviewCspSource = 'vscode-resource:';
constructor(private _args: ParsedArgs, private _execPath: string) {
if (!process.env['VSCODE_LOGS']) {
const key = toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '');

View File

@@ -9,7 +9,8 @@ import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGallery
import { assign, getOrDefault } from 'vs/base/common/objects';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPager } from 'vs/base/common/paging';
import { IRequestService, IRequestOptions, IRequestContext, asJson, asText, IHeaders } from 'vs/platform/request/common/request';
import { IRequestService, asJson, asText } from 'vs/platform/request/common/request';
import { IRequestOptions, IRequestContext, IHeaders } from 'vs/base/parts/request/common/request';
import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { generateUuid, isUUID } from 'vs/base/common/uuid';

View File

@@ -3,13 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRequestOptions, IRequestContext } from 'vs/platform/request/common/request';
import { IRequestOptions, IRequestContext } from 'vs/base/parts/request/common/request';
import { CancellationToken } from 'vs/base/common/cancellation';
import { canceled } from 'vs/base/common/errors';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { assign } from 'vs/base/common/objects';
import { VSBuffer, bufferToStream } from 'vs/base/common/buffer';
import { request } from 'vs/base/parts/request/browser/request';
/**
* This service exposes the `request` API, while using the global
@@ -28,69 +26,10 @@ export class RequestService {
request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
this.logService.trace('RequestService#request', options.url);
const authorization = this.configurationService.getValue<string>('http.proxyAuthorization');
if (authorization) {
options.headers = assign(options.headers || {}, { 'Proxy-Authorization': authorization });
if (!options.proxyAuthorization) {
options.proxyAuthorization = this.configurationService.getValue<string>('http.proxyAuthorization');
}
const xhr = new XMLHttpRequest();
return new Promise<IRequestContext>((resolve, reject) => {
xhr.open(options.type || 'GET', options.url || '', true, options.user, options.password);
this.setRequestHeaders(xhr, options);
xhr.responseType = 'arraybuffer';
xhr.onerror = e => reject(new Error(xhr.statusText && ('XHR failed: ' + xhr.statusText)));
xhr.onload = (e) => {
resolve({
res: {
statusCode: xhr.status,
headers: this.getResponseHeaders(xhr)
},
stream: bufferToStream(VSBuffer.wrap(new Uint8Array(xhr.response)))
});
};
xhr.ontimeout = e => reject(new Error(`XHR timeout: ${options.timeout}ms`));
if (options.timeout) {
xhr.timeout = options.timeout;
}
xhr.send(options.data);
// cancel
token.onCancellationRequested(() => {
xhr.abort();
reject(canceled());
});
});
return request(options, token);
}
private setRequestHeaders(xhr: XMLHttpRequest, options: IRequestOptions): void {
if (options.headers) {
outer: for (let k in options.headers) {
switch (k) {
case 'User-Agent':
case 'Accept-Encoding':
case 'Content-Length':
// unsafe headers
continue outer;
}
xhr.setRequestHeader(k, options.headers[k]);
}
}
}
private getResponseHeaders(xhr: XMLHttpRequest): { [name: string]: string } {
const headers: { [name: string]: string } = Object.create(null);
for (const line of xhr.getAllResponseHeaders().split(/\r\n|\n|\r/g)) {
if (line) {
const idx = line.indexOf(':');
headers[line.substr(0, idx).trim().toLowerCase()] = line.substr(idx + 1).trim();
}
}
return headers;
}
}
}

View File

@@ -8,33 +8,11 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import { VSBufferReadableStream, streamToBuffer } from 'vs/base/common/buffer';
import { streamToBuffer } from 'vs/base/common/buffer';
import { IRequestOptions, IRequestContext } from 'vs/base/parts/request/common/request';
export const IRequestService = createDecorator<IRequestService>('requestService');
export interface IHeaders {
[header: string]: string;
}
export interface IRequestOptions {
type?: string;
url?: string;
user?: string;
password?: string;
headers?: IHeaders;
timeout?: number;
data?: string;
followRedirects?: number;
}
export interface IRequestContext {
res: {
headers: IHeaders;
statusCode?: number;
};
stream: VSBufferReadableStream;
}
export interface IRequestService {
_serviceBrand: any;

View File

@@ -5,7 +5,8 @@
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { Event } from 'vs/base/common/event';
import { IRequestService, IRequestOptions, IRequestContext, IHeaders } from 'vs/platform/request/common/request';
import { IRequestService } from 'vs/platform/request/common/request';
import { IRequestOptions, IRequestContext, IHeaders } from 'vs/base/parts/request/common/request';
import { CancellationToken } from 'vs/base/common/cancellation';
import { VSBuffer, bufferToStream, streamToBuffer } from 'vs/base/common/buffer';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRequestOptions, IRequestContext } from 'vs/platform/request/common/request';
import { IRequestOptions, IRequestContext } from 'vs/base/parts/request/common/request';
import { RequestService as NodeRequestService, IRawRequestFunction } from 'vs/platform/request/node/requestService';
import { assign } from 'vs/base/common/objects';
import { net } from 'electron';

View File

@@ -13,7 +13,8 @@ import { assign } from 'vs/base/common/objects';
import { isBoolean, isNumber } from 'vs/base/common/types';
import { canceled } from 'vs/base/common/errors';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IRequestOptions, IRequestContext, IRequestService, IHTTPConfiguration } from 'vs/platform/request/common/request';
import { IRequestService, IHTTPConfiguration } from 'vs/platform/request/common/request';
import { IRequestOptions, IRequestContext } from 'vs/base/parts/request/common/request';
import { getProxyAgent, Agent } from 'vs/platform/request/node/proxy';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';