Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421 (#7404)

* Merge from vscode e0762af258c0b20320ed03f3871a41967acc4421

* readd svgs
This commit is contained in:
Anthony Dresser
2019-09-27 11:13:19 -07:00
committed by GitHub
parent 6385443a4c
commit 07109617b5
348 changed files with 4219 additions and 4307 deletions

View File

@@ -11,9 +11,10 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { EditorGroupLayout } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IOpenSettings, IURIToOpen, IWindowService } from 'vs/platform/windows/common/windows';
import { IOpenInWindowOptions, IWindowOpenable } from 'vs/platform/windows/common/windows';
import { IWorkspacesHistoryService } from 'vs/workbench/services/workspace/common/workspacesHistoryService';
import { IWorkspacesService, hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { IRecent } from 'vs/platform/history/common/history';
import { IRecent } from 'vs/platform/workspaces/common/workspacesHistory';
import { Schemas } from 'vs/base/common/network';
// -----------------------------------------------------------------
@@ -50,9 +51,9 @@ export class OpenFolderAPICommand {
if (!uri) {
return executor.executeCommand('_files.pickFolderAndOpen', { forceNewWindow: arg.forceNewWindow });
}
const options: IOpenSettings = { forceNewWindow: arg.forceNewWindow, forceReuseWindow: arg.forceReuseWindow, noRecentEntry: arg.noRecentEntry };
const options: IOpenInWindowOptions = { forceNewWindow: arg.forceNewWindow, forceReuseWindow: arg.forceReuseWindow, noRecentEntry: arg.noRecentEntry };
uri = URI.revive(uri);
const uriToOpen: IURIToOpen = (hasWorkspaceFileExtension(uri) || uri.scheme === Schemas.untitled) ? { workspaceUri: uri } : { folderUri: uri };
const uriToOpen: IWindowOpenable = (hasWorkspaceFileExtension(uri) || uri.scheme === Schemas.untitled) ? { workspaceUri: uri } : { folderUri: uri };
return executor.executeCommand('_files.windowOpen', [uriToOpen], options);
}
}
@@ -132,8 +133,8 @@ export class OpenAPICommand {
CommandsRegistry.registerCommand(OpenAPICommand.ID, adjustHandler(OpenAPICommand.execute));
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, uri: URI) {
const windowService = accessor.get(IWindowService);
return windowService.removeFromRecentlyOpened([uri]);
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
return workspacesHistoryService.removeFromRecentlyOpened([uri]);
});
export class RemoveFromRecentlyOpenedAPICommand {
@@ -163,7 +164,7 @@ interface RecentEntry {
}
CommandsRegistry.registerCommand('_workbench.addToRecentlyOpened', async function (accessor: ServicesAccessor, recentEntry: RecentEntry) {
const windowService = accessor.get(IWindowService);
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
const workspacesService = accessor.get(IWorkspacesService);
let recent: IRecent | undefined = undefined;
const uri = recentEntry.uri;
@@ -176,12 +177,12 @@ CommandsRegistry.registerCommand('_workbench.addToRecentlyOpened', async functio
} else {
recent = { fileUri: uri, label };
}
return windowService.addRecentlyOpened([recent]);
return workspacesHistoryService.addRecentlyOpened([recent]);
});
CommandsRegistry.registerCommand('_workbench.getRecentlyOpened', async function (accessor: ServicesAccessor) {
const windowService = accessor.get(IWindowService);
return windowService.getRecentlyOpened();
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
return workspacesHistoryService.getRecentlyOpened();
});
export class SetEditorLayoutAPICommand {

View File

@@ -537,7 +537,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
},
registerWebviewEditorProvider: (viewType: string, provider: vscode.WebviewEditorProvider) => {
checkProposedApiEnabled(extension);
return extHostWebviews.registerWebviewEditorProvider(viewType, provider);
return extHostWebviews.registerWebviewEditorProvider(extension, viewType, provider);
},
registerDecorationProvider(provider: vscode.DecorationProvider) {
checkProposedApiEnabled(extension);
@@ -912,7 +912,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
CallHierarchyItem: extHostTypes.CallHierarchyItem,
DebugConsoleMode: extHostTypes.DebugConsoleMode,
Decoration: extHostTypes.Decoration,
WebviewEditorState: extHostTypes.WebviewEditorState,
WebviewContentState: extHostTypes.WebviewContentState,
UIKind: UIKind
};
};

View File

@@ -32,7 +32,7 @@ import { IMarkerData } from 'vs/platform/markers/common/markers';
import { IProgressOptions, IProgressStep } from 'vs/platform/progress/common/progress';
import * as quickInput from 'vs/platform/quickinput/common/quickInput';
import { RemoteAuthorityResolverErrorCode, ResolverResult } from 'vs/platform/remote/common/remoteAuthorityResolver';
import * as statusbar from 'vs/platform/statusbar/common/statusbar';
import * as statusbar from 'vs/workbench/services/statusbar/common/statusbar';
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
import { ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
@@ -549,11 +549,13 @@ export interface MainThreadWebviewsShape extends IDisposable {
$disposeWebview(handle: WebviewPanelHandle): void;
$reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void;
$setTitle(handle: WebviewPanelHandle, value: string): void;
$setState(handle: WebviewPanelHandle, state: modes.WebviewEditorState): void;
$setState(handle: WebviewPanelHandle, state: modes.WebviewContentState): void;
$setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void;
$setHtml(handle: WebviewPanelHandle, value: string): void;
$setOptions(handle: WebviewPanelHandle, options: modes.IWebviewOptions): void;
$setExtension(handle: WebviewPanelHandle, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void;
$postMessage(handle: WebviewPanelHandle, value: any): Promise<boolean>;
$registerSerializer(viewType: string): void;

View File

@@ -52,7 +52,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
{
processArgument(a) {
// URI, Regex
return revive(a, 0);
return revive(a);
}
},
{
@@ -141,7 +141,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
try {
const result = await this._proxy.$executeCommand<T>(id, toArgs, retry);
return revive(result, 0);
return revive(result);
} catch (e) {
// Rerun the command when it wasn't known, had arguments, and when retry
// is enabled. We do this because the command might be registered inside

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar';
import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/workbench/services/statusbar/common/statusbar';
import { StatusBarAlignment as ExtHostStatusBarAlignment, Disposable, ThemeColor } from './extHostTypes';
import { StatusBarItem, StatusBarAlignment } from 'vscode';
import { MainContext, MainThreadStatusBarShape, IMainContext } from './extHost.protocol';

View File

@@ -373,9 +373,9 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
protected _handleCounter: number;
protected _handlers: Map<number, HandlerData>;
protected _taskExecutions: Map<string, TaskExecutionImpl>;
protected _providedCustomExecutions2: Map<string, vscode.CustomExecution2>;
protected _providedCustomExecutions2: Map<string, types.CustomExecution2>;
private _notProvidedCustomExecutions: Set<string>; // Used for custom executions tasks that are created and run through executeTask.
protected _activeCustomExecutions2: Map<string, vscode.CustomExecution2>;
protected _activeCustomExecutions2: Map<string, types.CustomExecution2>;
private _lastStartedTask: string | undefined;
protected readonly _onDidExecuteTask: Emitter<vscode.TaskStartEvent> = new Emitter<vscode.TaskStartEvent>();
protected readonly _onDidTerminateTask: Emitter<vscode.TaskEndEvent> = new Emitter<vscode.TaskEndEvent>();
@@ -399,9 +399,9 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
this._handleCounter = 0;
this._handlers = new Map<number, HandlerData>();
this._taskExecutions = new Map<string, TaskExecutionImpl>();
this._providedCustomExecutions2 = new Map<string, vscode.CustomExecution2>();
this._providedCustomExecutions2 = new Map<string, types.CustomExecution2>();
this._notProvidedCustomExecutions = new Set<string>();
this._activeCustomExecutions2 = new Map<string, vscode.CustomExecution2>();
this._activeCustomExecutions2 = new Map<string, types.CustomExecution2>();
}
public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable {
@@ -454,7 +454,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
}
public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number): Promise<void> {
const execution2: vscode.CustomExecution2 | undefined = this._providedCustomExecutions2.get(execution.id);
const execution2: types.CustomExecution2 | undefined = this._providedCustomExecutions2.get(execution.id);
if (execution2) {
if (this._activeCustomExecutions2.get(execution.id) !== undefined) {
throw new Error('We should not be trying to start the same custom task executions twice.');
@@ -593,7 +593,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
if (!isProvided && !this._providedCustomExecutions2.has(taskId)) {
this._notProvidedCustomExecutions.add(taskId);
}
this._providedCustomExecutions2.set(taskId, <vscode.CustomExecution2>(<vscode.Task2>task).execution2);
this._providedCustomExecutions2.set(taskId, <types.CustomExecution2>(<vscode.Task2>task).execution2);
}
protected async getTaskExecution(execution: tasks.TaskExecutionDTO | string, task?: vscode.Task): Promise<TaskExecutionImpl> {

View File

@@ -1163,13 +1163,13 @@ export namespace LogLevel {
return types.LogLevel.Info;
}
}
export namespace WebviewEditorState {
export function from(state: vscode.WebviewEditorState): modes.WebviewEditorState {
export namespace WebviewContentState {
export function from(state: vscode.WebviewContentState): modes.WebviewContentState {
switch (state) {
case types.WebviewEditorState.Readonly: return modes.WebviewEditorState.Readonly;
case types.WebviewEditorState.Unchanged: return modes.WebviewEditorState.Unchanged;
case types.WebviewEditorState.Dirty: return modes.WebviewEditorState.Dirty;
default: throw new Error('Unknown vscode.WebviewEditorState');
case types.WebviewContentState.Readonly: return modes.WebviewContentState.Readonly;
case types.WebviewContentState.Unchanged: return modes.WebviewContentState.Unchanged;
case types.WebviewContentState.Dirty: return modes.WebviewContentState.Dirty;
default: throw new Error('Unknown vscode.WebviewContentState');
}
}
}

View File

@@ -2399,7 +2399,7 @@ export class Decoration {
bubble?: boolean;
}
export enum WebviewEditorState {
export enum WebviewContentState {
Readonly = 1,
Unchanged = 2,
Dirty = 3,

View File

@@ -13,7 +13,7 @@ import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { asWebviewUri, WebviewInitData } from 'vs/workbench/api/common/shared/webview';
import * as vscode from 'vscode';
import { ExtHostWebviewsShape, IMainContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelViewStateData } from './extHost.protocol';
import { Disposable, WebviewEditorState } from './extHostTypes';
import { Disposable, WebviewContentState } from './extHostTypes';
type IconPath = URI | { light: URI, dark: URI };
@@ -93,7 +93,9 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
private _viewColumn: vscode.ViewColumn | undefined;
private _visible: boolean = true;
private _active: boolean = true;
private _state = WebviewEditorState.Readonly;
private _state: vscode.WebviewEditorState = {
contentState: WebviewContentState.Readonly,
};
_isDisposed: boolean = false;
@@ -103,7 +105,6 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
readonly _onDidChangeViewStateEmitter = new Emitter<vscode.WebviewPanelOnDidChangeViewStateEvent>();
public readonly onDidChangeViewState: Event<vscode.WebviewPanelOnDidChangeViewStateEvent> = this._onDidChangeViewStateEmitter.event;
constructor(
handle: WebviewPanelHandle,
proxy: MainThreadWebviewsShape,
@@ -214,13 +215,13 @@ export class ExtHostWebviewEditor implements vscode.WebviewEditor {
this._visible = value;
}
public get state(): vscode.WebviewEditorState {
public get editorState(): vscode.WebviewEditorState {
return this._state;
}
public set state(newState: vscode.WebviewEditorState) {
public set editorState(newState: vscode.WebviewEditorState) {
this._state = newState;
this._proxy.$setState(this._handle, typeConverters.WebviewEditorState.from(newState));
this._proxy.$setState(this._handle, typeConverters.WebviewContentState.from(newState.contentState));
}
private readonly _onWillSave = new Emitter<{ waitUntil: (thenable: Thenable<boolean>) => void }>();
@@ -264,7 +265,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
private readonly _proxy: MainThreadWebviewsShape;
private readonly _webviewPanels = new Map<WebviewPanelHandle, ExtHostWebviewEditor>();
private readonly _serializers = new Map<string, vscode.WebviewPanelSerializer>();
private readonly _editorProviders = new Map<string, vscode.WebviewEditorProvider>();
private readonly _editorProviders = new Map<string, { readonly provider: vscode.WebviewEditorProvider, readonly extension: IExtensionDescription }>();
constructor(
mainContext: IMainContext,
@@ -313,14 +314,15 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
}
public registerWebviewEditorProvider(
extension: IExtensionDescription,
viewType: string,
provider: vscode.WebviewEditorProvider
provider: vscode.WebviewEditorProvider,
): vscode.Disposable {
if (this._editorProviders.has(viewType)) {
throw new Error(`Editor provider for '${viewType}' already registered`);
}
this._editorProviders.set(viewType, provider);
this._editorProviders.set(viewType, { extension, provider, });
this._proxy.$registerEditorProvider(viewType);
return new Disposable(() => {
@@ -415,21 +417,24 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
async $resolveWebviewEditor(
resource: UriComponents,
webviewHandle: WebviewPanelHandle,
handle: WebviewPanelHandle,
viewType: string,
title: string,
state: any,
position: EditorViewColumn,
options: modes.IWebviewOptions & modes.IWebviewPanelOptions
): Promise<void> {
const provider = this._editorProviders.get(viewType);
if (!provider) {
const entry = this._editorProviders.get(viewType);
if (!entry) {
return Promise.reject(new Error(`No provider found for '${viewType}'`));
}
const { provider, extension } = entry;
const webview = new ExtHostWebview(webviewHandle, this._proxy, options, this.initData);
const revivedPanel = new ExtHostWebviewEditor(webviewHandle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
this._webviewPanels.set(webviewHandle, revivedPanel);
this._proxy.$setExtension(handle, extension.identifier, extension.extensionLocation);
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData);
const revivedPanel = new ExtHostWebviewEditor(handle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
this._webviewPanels.set(handle, revivedPanel);
return Promise.resolve(provider.resolveWebviewEditor(URI.revive(resource), revivedPanel));
}

View File

@@ -17,7 +17,13 @@ export function asWebviewUri(
resource: vscode.Uri,
): vscode.Uri {
const uri = initData.webviewResourceRoot
.replace('{{resource}}', resource.toString().replace(/^\S+?:/, ''))
// Make sure we preserve the scheme of the resource but convert it into a normal path segment
// The scheme is important as we need to know if we are requesting a local or a remote resource.
.replace('{{resource}}', resource.scheme + withoutScheme(resource))
.replace('{{uuid}}', uuid);
return URI.parse(uri);
}
function withoutScheme(resource: vscode.Uri): string {
return resource.toString().replace(/^\S+?:/, '');
}