mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 099a7622e6e90dbcc226e428d4e35a72cb19ecbc (#9646)
* Merge from vscode 099a7622e6e90dbcc226e428d4e35a72cb19ecbc * fix strict
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore, Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ExtHostContext, ExtHostTerminalServiceShape, MainThreadTerminalServiceShape, MainContext, IExtHostContext, IShellLaunchConfigDto, TerminalLaunchConfig, ITerminalDimensionsDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { StopWatch } from 'vs/base/common/stopwatch';
|
||||
import { ITerminalInstanceService, ITerminalService, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ITerminalInstanceService, ITerminalService, ITerminalInstance, ITerminalBeforeHandleLinkEvent } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TerminalDataBufferer } from 'vs/workbench/contrib/terminal/common/terminalDataBuffering';
|
||||
@@ -23,6 +23,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||
private readonly _terminalProcesses = new Map<number, Promise<ITerminalProcessExtHostProxy>>();
|
||||
private readonly _terminalProcessesReady = new Map<number, (proxy: ITerminalProcessExtHostProxy) => void>();
|
||||
private _dataEventTracker: TerminalDataEventTracker | undefined;
|
||||
private _linkHandler: IDisposable | undefined;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -146,6 +147,22 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||
}
|
||||
}
|
||||
|
||||
public $startHandlingLinks(): void {
|
||||
this._linkHandler?.dispose();
|
||||
this._linkHandler = this._terminalService.addLinkHandler(this._remoteAuthority || '', e => this._handleLink(e));
|
||||
}
|
||||
|
||||
public $stopHandlingLinks(): void {
|
||||
this._linkHandler?.dispose();
|
||||
}
|
||||
|
||||
private async _handleLink(e: ITerminalBeforeHandleLinkEvent): Promise<boolean> {
|
||||
if (!e.terminal) {
|
||||
return false;
|
||||
}
|
||||
return this._proxy.$handleLink(e.terminal.id, e.link);
|
||||
}
|
||||
|
||||
private _onActiveTerminalChanged(terminalId: number | null): void {
|
||||
this._proxy.$acceptActiveTerminalChanged(terminalId);
|
||||
}
|
||||
|
||||
@@ -279,12 +279,12 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
this._revivers.delete(viewType);
|
||||
}
|
||||
|
||||
public $registerTextEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void {
|
||||
return this.registerEditorProvider(ModelType.Text, extensionData, viewType, options);
|
||||
public $registerTextEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions, capabilities: extHostProtocol.CustomTextEditorCapabilities): void {
|
||||
this.registerEditorProvider(ModelType.Text, extensionData, viewType, options, capabilities);
|
||||
}
|
||||
|
||||
public $registerCustomEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void {
|
||||
return this.registerEditorProvider(ModelType.Custom, extensionData, viewType, options);
|
||||
this.registerEditorProvider(ModelType.Custom, extensionData, viewType, options, {});
|
||||
}
|
||||
|
||||
private registerEditorProvider(
|
||||
@@ -292,41 +292,45 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
extensionData: extHostProtocol.WebviewExtensionDescription,
|
||||
viewType: string,
|
||||
options: modes.IWebviewPanelOptions,
|
||||
): void {
|
||||
capabilities: extHostProtocol.CustomTextEditorCapabilities,
|
||||
): DisposableStore {
|
||||
if (this._editorProviders.has(viewType)) {
|
||||
throw new Error(`Provider for ${viewType} already registered`);
|
||||
}
|
||||
|
||||
const extension = reviveWebviewExtension(extensionData);
|
||||
|
||||
this._editorProviders.set(viewType, this._webviewWorkbenchService.registerResolver({
|
||||
const disposables = new DisposableStore();
|
||||
disposables.add(this._webviewWorkbenchService.registerResolver({
|
||||
canResolve: (webviewInput) => {
|
||||
return webviewInput instanceof CustomEditorInput && webviewInput.viewType === viewType;
|
||||
},
|
||||
resolveWebview: async (webviewInput: CustomEditorInput) => {
|
||||
const handle = webviewInput.id;
|
||||
this._webviewInputs.add(handle, webviewInput);
|
||||
this.hookupWebviewEventDelegate(handle, webviewInput);
|
||||
|
||||
this.hookupWebviewEventDelegate(handle, webviewInput);
|
||||
webviewInput.webview.options = options;
|
||||
webviewInput.webview.extension = extension;
|
||||
|
||||
const resource = webviewInput.resource;
|
||||
let modelRef = await this.getOrCreateCustomEditorModel(modelType, resource, viewType);
|
||||
|
||||
const modelRef = await this.getOrCreateCustomEditorModel(modelType, webviewInput, resource, viewType);
|
||||
webviewInput.webview.onDispose(() => {
|
||||
modelRef.dispose();
|
||||
});
|
||||
|
||||
if (capabilities.supportsMove) {
|
||||
webviewInput.onMove(async (newResource: URI) => {
|
||||
const oldModel = modelRef;
|
||||
modelRef = await this.getOrCreateCustomEditorModel(modelType, newResource, viewType);
|
||||
this._proxy.$onMoveCustomEditor(handle, newResource, viewType);
|
||||
oldModel.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await this._proxy.$resolveWebviewEditor(
|
||||
resource,
|
||||
handle,
|
||||
viewType,
|
||||
webviewInput.getTitle(),
|
||||
editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0),
|
||||
webviewInput.webview.options
|
||||
);
|
||||
await this._proxy.$resolveWebviewEditor(resource, handle, viewType, webviewInput.getTitle(), editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0), webviewInput.webview.options);
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
webviewInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
|
||||
@@ -334,6 +338,10 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
this._editorProviders.set(viewType, disposables);
|
||||
|
||||
return disposables;
|
||||
}
|
||||
|
||||
public $unregisterEditorProvider(viewType: string): void {
|
||||
@@ -350,11 +358,10 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
|
||||
private async getOrCreateCustomEditorModel(
|
||||
modelType: ModelType,
|
||||
webviewInput: WebviewInput,
|
||||
resource: URI,
|
||||
viewType: string,
|
||||
): Promise<IReference<ICustomEditorModel>> {
|
||||
const existingModel = this._customEditorService.models.tryRetain(webviewInput.resource, webviewInput.viewType);
|
||||
const existingModel = this._customEditorService.models.tryRetain(resource, viewType);
|
||||
if (existingModel) {
|
||||
return existingModel;
|
||||
}
|
||||
@@ -383,14 +390,13 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
|
||||
disposables.add(input.webview.onMessage((message: any) => { this._proxy.$onMessage(handle, message); }));
|
||||
disposables.add(input.webview.onMissingCsp((extension: ExtensionIdentifier) => this._proxy.$onMissingCsp(handle, extension.value)));
|
||||
|
||||
input.onDispose(() => {
|
||||
disposables.add(input.webview.onDispose(() => {
|
||||
disposables.dispose();
|
||||
});
|
||||
input.webview.onDispose(() => {
|
||||
|
||||
this._proxy.$onDidDisposeWebviewPanel(handle).finally(() => {
|
||||
this._webviewInputs.delete(handle);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private registerWebviewFromDiffEditorListeners(diffEditorInput: DiffEditorInput): void {
|
||||
@@ -536,6 +542,8 @@ namespace HotExitState {
|
||||
export type State = typeof Allowed | typeof NotAllowed | Pending;
|
||||
}
|
||||
|
||||
const customDocumentFileScheme = 'custom';
|
||||
|
||||
class MainThreadCustomEditorModel extends Disposable implements ICustomEditorModel, IWorkingCopy {
|
||||
|
||||
private _hotExitState: HotExitState.State = HotExitState.Allowed;
|
||||
@@ -556,7 +564,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
constructor(
|
||||
private readonly _proxy: extHostProtocol.ExtHostWebviewsShape,
|
||||
private readonly _viewType: string,
|
||||
private readonly _resource: URI,
|
||||
private readonly _realResource: URI,
|
||||
private readonly _editable: boolean,
|
||||
@IWorkingCopyService workingCopyService: IWorkingCopyService,
|
||||
@ILabelService private readonly _labelService: ILabelService,
|
||||
@@ -564,6 +572,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
@IUndoRedoService private readonly _undoService: IUndoRedoService,
|
||||
) {
|
||||
super();
|
||||
|
||||
if (_editable) {
|
||||
this._register(workingCopyService.registerWorkingCopy(this));
|
||||
}
|
||||
@@ -571,18 +580,26 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
|
||||
dispose() {
|
||||
if (this._editable) {
|
||||
this._undoService.removeElements(this.resource);
|
||||
this._undoService.removeElements(this._realResource);
|
||||
}
|
||||
this._proxy.$disposeWebviewCustomEditorDocument(this.resource, this._viewType);
|
||||
this._proxy.$disposeWebviewCustomEditorDocument(this._realResource, this._viewType);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
//#region IWorkingCopy
|
||||
|
||||
public get resource() { return this._resource; } // custom://viewType/path/file
|
||||
public get resource() {
|
||||
// Make sure each custom editor has a unique resource for backup and edits
|
||||
return URI.from({
|
||||
scheme: customDocumentFileScheme,
|
||||
authority: this._viewType,
|
||||
path: this._realResource.path,
|
||||
query: JSON.stringify(this._realResource.toJSON())
|
||||
});
|
||||
}
|
||||
|
||||
public get name() {
|
||||
return basename(this._labelService.getUriLabel(this._resource));
|
||||
return basename(this._labelService.getUriLabel(this._realResource));
|
||||
}
|
||||
|
||||
public get capabilities(): WorkingCopyCapabilities {
|
||||
@@ -601,6 +618,10 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
|
||||
//#endregion
|
||||
|
||||
public isReadonly() {
|
||||
return this._editable;
|
||||
}
|
||||
|
||||
public get viewType() {
|
||||
return this._viewType;
|
||||
}
|
||||
@@ -617,7 +638,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
|
||||
this._undoService.pushElement({
|
||||
type: UndoRedoElementType.Resource,
|
||||
resource: this.resource,
|
||||
resource: this._realResource,
|
||||
label: label ?? localize('defaultEditLabel', "Edit"),
|
||||
undo: () => this.undo(),
|
||||
redo: () => this.redo(),
|
||||
@@ -635,7 +656,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
}
|
||||
|
||||
const undoneEdit = this._edits[this._currentEditIndex];
|
||||
await this._proxy.$undo(this.resource, this.viewType, undoneEdit);
|
||||
await this._proxy.$undo(this._realResource, this.viewType, undoneEdit);
|
||||
|
||||
this.change(() => {
|
||||
--this._currentEditIndex;
|
||||
@@ -653,7 +674,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
}
|
||||
|
||||
const redoneEdit = this._edits[this._currentEditIndex + 1];
|
||||
await this._proxy.$redo(this.resource, this.viewType, redoneEdit);
|
||||
await this._proxy.$redo(this._realResource, this.viewType, redoneEdit);
|
||||
this.change(() => {
|
||||
++this._currentEditIndex;
|
||||
});
|
||||
@@ -668,7 +689,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
: this._edits.splice(start, toRemove);
|
||||
|
||||
if (removedEdits.length) {
|
||||
this._proxy.$disposeEdits(this.resource, this._viewType, removedEdits);
|
||||
this._proxy.$disposeEdits(this._realResource, this._viewType, removedEdits);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,7 +721,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
editsToRedo = this._edits.slice(this._currentEditIndex, this._savePoint);
|
||||
}
|
||||
|
||||
this._proxy.$revert(this.resource, this.viewType, { undoneEdits: editsToUndo, redoneEdits: editsToRedo });
|
||||
this._proxy.$revert(this._realResource, this.viewType, { undoneEdits: editsToUndo, redoneEdits: editsToRedo });
|
||||
this.change(() => {
|
||||
this._currentEditIndex = this._savePoint;
|
||||
this.spliceEdits();
|
||||
@@ -711,7 +732,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
if (!this._editable) {
|
||||
return false;
|
||||
}
|
||||
await createCancelablePromise(token => this._proxy.$onSave(this.resource, this.viewType, token));
|
||||
await createCancelablePromise(token => this._proxy.$onSave(this._realResource, this.viewType, token));
|
||||
this.change(() => {
|
||||
this._savePoint = this._currentEditIndex;
|
||||
});
|
||||
@@ -720,7 +741,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
|
||||
public async saveAs(resource: URI, targetResource: URI, _options?: ISaveOptions): Promise<boolean> {
|
||||
if (this._editable) {
|
||||
await this._proxy.$onSaveAs(this.resource, this.viewType, targetResource);
|
||||
await this._proxy.$onSaveAs(this._realResource, this.viewType, targetResource);
|
||||
this.change(() => {
|
||||
this._savePoint = this._currentEditIndex;
|
||||
});
|
||||
@@ -749,7 +770,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
|
||||
|
||||
const pendingState = new HotExitState.Pending(
|
||||
createCancelablePromise(token =>
|
||||
this._proxy.$backup(this.resource.toJSON(), this.viewType, token)));
|
||||
this._proxy.$backup(this._realResource.toJSON(), this.viewType, token)));
|
||||
this._hotExitState = pendingState;
|
||||
|
||||
try {
|
||||
|
||||
@@ -543,7 +543,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
return extHostProgress.withProgress(extension, { location: extHostTypes.ProgressLocation.SourceControl }, (progress, token) => task({ report(n: number) { /*noop*/ } }));
|
||||
},
|
||||
withProgress<R>(options: vscode.ProgressOptions, task: (progress: vscode.Progress<{ message?: string; worked?: number }>, token: vscode.CancellationToken) => Thenable<R>) {
|
||||
if (options.location === extHostTypes.ProgressLocation.View) {
|
||||
if (typeof options.location === 'object') {
|
||||
checkProposedApiEnabled(extension);
|
||||
}
|
||||
return extHostProgress.withProgress(extension, options, task);
|
||||
@@ -567,6 +567,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
}
|
||||
return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs);
|
||||
},
|
||||
registerTerminalLinkHandler(handler: vscode.TerminalLinkHandler): vscode.Disposable {
|
||||
checkProposedApiEnabled(extension);
|
||||
return extHostTerminalService.registerLinkHandler(handler);
|
||||
},
|
||||
registerTreeDataProvider(viewId: string, treeDataProvider: vscode.TreeDataProvider<any>): vscode.Disposable {
|
||||
return extHostTreeViews.registerTreeDataProvider(viewId, treeDataProvider, extension);
|
||||
},
|
||||
|
||||
@@ -70,6 +70,7 @@ export interface IEnvironment {
|
||||
userHome: URI;
|
||||
webviewResourceRoot: string;
|
||||
webviewCspSource: string;
|
||||
useHostProxy?: boolean;
|
||||
}
|
||||
|
||||
export interface IStaticWorkspaceData {
|
||||
@@ -435,6 +436,8 @@ export interface MainThreadTerminalServiceShape extends IDisposable {
|
||||
$show(terminalId: number, preserveFocus: boolean): void;
|
||||
$startSendingDataEvents(): void;
|
||||
$stopSendingDataEvents(): void;
|
||||
$startHandlingLinks(): void;
|
||||
$stopHandlingLinks(): void;
|
||||
|
||||
// Process
|
||||
$sendProcessTitle(terminalId: number, title: string): void;
|
||||
@@ -577,6 +580,10 @@ export interface WebviewExtensionDescription {
|
||||
readonly location: UriComponents;
|
||||
}
|
||||
|
||||
export interface CustomTextEditorCapabilities {
|
||||
readonly supportsMove?: boolean;
|
||||
}
|
||||
|
||||
export interface MainThreadWebviewsShape extends IDisposable {
|
||||
$createWebviewPanel(extension: WebviewExtensionDescription, handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: modes.IWebviewPanelOptions & modes.IWebviewOptions): void;
|
||||
$disposeWebview(handle: WebviewPanelHandle): void;
|
||||
@@ -592,7 +599,7 @@ export interface MainThreadWebviewsShape extends IDisposable {
|
||||
$registerSerializer(viewType: string): void;
|
||||
$unregisterSerializer(viewType: string): void;
|
||||
|
||||
$registerTextEditorProvider(extension: WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void;
|
||||
$registerTextEditorProvider(extension: WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions, capabilities: CustomTextEditorCapabilities): void;
|
||||
$registerCustomEditorProvider(extension: WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void;
|
||||
$unregisterEditorProvider(viewType: string): void;
|
||||
|
||||
@@ -628,6 +635,8 @@ export interface ExtHostWebviewsShape {
|
||||
$onSaveAs(resource: UriComponents, viewType: string, targetResource: UriComponents): Promise<void>;
|
||||
|
||||
$backup(resource: UriComponents, viewType: string, cancellation: CancellationToken): Promise<void>;
|
||||
|
||||
$onMoveCustomEditor(handle: WebviewPanelHandle, newResource: UriComponents, viewType: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface MainThreadUrlsShape extends IDisposable {
|
||||
@@ -1315,6 +1324,7 @@ export interface ExtHostTerminalServiceShape {
|
||||
$acceptWorkspacePermissionsChanged(isAllowed: boolean): void;
|
||||
$getAvailableShells(): Promise<IShellDefinitionDto[]>;
|
||||
$getDefaultShellAndArgs(useAutomationShell: boolean): Promise<IShellAndArgsDto>;
|
||||
$handleLink(id: number, link: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface ExtHostSCMShape {
|
||||
|
||||
@@ -24,10 +24,10 @@ export class ExtHostProgress implements ExtHostProgressShape {
|
||||
|
||||
withProgress<R>(extension: IExtensionDescription, options: ProgressOptions, task: (progress: Progress<IProgressStep>, token: CancellationToken) => Thenable<R>): Thenable<R> {
|
||||
const handle = this._handles++;
|
||||
const { title, location, cancellable, viewId } = options;
|
||||
const { title, location, cancellable } = options;
|
||||
const source = localize('extensionSource', "{0} (Extension)", extension.displayName || extension.name);
|
||||
|
||||
this._proxy.$startProgress(handle, { location: ProgressLocation.from(location, viewId), title, source, cancellable }, extension);
|
||||
this._proxy.$startProgress(handle, { location: ProgressLocation.from(location), title, source, cancellable }, extension);
|
||||
return this._withProgress(handle, task, !!cancellable);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { timeout } from 'vs/base/common/async';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { TerminalDataBufferer } from 'vs/workbench/contrib/terminal/common/terminalDataBuffering';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Disposable as VSCodeDisposable } from './extHostTypes';
|
||||
|
||||
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape {
|
||||
|
||||
@@ -34,6 +35,7 @@ export interface IExtHostTerminalService extends ExtHostTerminalServiceShape {
|
||||
attachPtyToTerminal(id: number, pty: vscode.Pseudoterminal): void;
|
||||
getDefaultShell(useAutomationShell: boolean, configProvider: ExtHostConfigProvider): string;
|
||||
getDefaultShellArgs(useAutomationShell: boolean, configProvider: ExtHostConfigProvider): string[] | string;
|
||||
registerLinkHandler(handler: vscode.TerminalLinkHandler): vscode.Disposable
|
||||
}
|
||||
|
||||
export const IExtHostTerminalService = createDecorator<IExtHostTerminalService>('IExtHostTerminalService');
|
||||
@@ -295,6 +297,9 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
|
||||
protected _extensionTerminalAwaitingStart: { [id: number]: { initialDimensions: ITerminalDimensionsDto | undefined } | undefined } = {};
|
||||
protected _getTerminalPromises: { [id: number]: Promise<ExtHostTerminal> } = {};
|
||||
|
||||
private readonly _bufferer: TerminalDataBufferer;
|
||||
private readonly _linkHandlers: Set<vscode.TerminalLinkHandler> = new Set();
|
||||
|
||||
public get activeTerminal(): ExtHostTerminal | undefined { return this._activeTerminal; }
|
||||
public get terminals(): ExtHostTerminal[] { return this._terminals; }
|
||||
|
||||
@@ -309,8 +314,6 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
|
||||
protected readonly _onDidWriteTerminalData: Emitter<vscode.TerminalDataWriteEvent>;
|
||||
public get onDidWriteTerminalData(): Event<vscode.TerminalDataWriteEvent> { return this._onDidWriteTerminalData && this._onDidWriteTerminalData.event; }
|
||||
|
||||
private readonly _bufferer: TerminalDataBufferer;
|
||||
|
||||
constructor(
|
||||
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
||||
) {
|
||||
@@ -535,6 +538,38 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
|
||||
return id;
|
||||
}
|
||||
|
||||
public registerLinkHandler(handler: vscode.TerminalLinkHandler): vscode.Disposable {
|
||||
this._linkHandlers.add(handler);
|
||||
if (this._linkHandlers.size === 1) {
|
||||
this._proxy.$startHandlingLinks();
|
||||
}
|
||||
return new VSCodeDisposable(() => {
|
||||
this._linkHandlers.delete(handler);
|
||||
if (this._linkHandlers.size === 0) {
|
||||
this._proxy.$stopHandlingLinks();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async $handleLink(id: number, link: string): Promise<boolean> {
|
||||
const terminal = this._getTerminalById(id);
|
||||
if (!terminal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call each handler synchronously so multiple handlers aren't triggered at once
|
||||
const it = this._linkHandlers.values();
|
||||
let next = it.next();
|
||||
while (!next.done) {
|
||||
const handled = await next.value.handleLink(terminal, link);
|
||||
if (handled) {
|
||||
return true;
|
||||
}
|
||||
next = it.next();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private _onProcessExit(id: number, exitCode: number | undefined): void {
|
||||
this._bufferer.stopBuffering(id);
|
||||
|
||||
|
||||
@@ -1093,12 +1093,15 @@ export namespace EndOfLine {
|
||||
}
|
||||
|
||||
export namespace ProgressLocation {
|
||||
export function from(loc: vscode.ProgressLocation, viewId?: string): MainProgressLocation | string {
|
||||
export function from(loc: vscode.ProgressLocation | { viewId: string }): MainProgressLocation | string {
|
||||
if (typeof loc === 'object') {
|
||||
return loc.viewId;
|
||||
}
|
||||
|
||||
switch (loc) {
|
||||
case types.ProgressLocation.SourceControl: return MainProgressLocation.Scm;
|
||||
case types.ProgressLocation.Window: return MainProgressLocation.Window;
|
||||
case types.ProgressLocation.Notification: return MainProgressLocation.Notification;
|
||||
case types.ProgressLocation.View: return viewId ?? '';
|
||||
}
|
||||
throw new Error(`Unknown 'ProgressLocation'`);
|
||||
}
|
||||
|
||||
@@ -2082,8 +2082,7 @@ export class Task implements vscode.Task2 {
|
||||
export enum ProgressLocation {
|
||||
SourceControl = 1,
|
||||
Window = 10,
|
||||
Notification = 15,
|
||||
View = 25
|
||||
Notification = 15
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
|
||||
@@ -488,7 +488,9 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
const disposables = new DisposableStore();
|
||||
if ('resolveCustomTextEditor' in provider) {
|
||||
disposables.add(this._editorProviders.addTextProvider(viewType, extension, provider));
|
||||
this._proxy.$registerTextEditorProvider(toExtensionData(extension), viewType, options);
|
||||
this._proxy.$registerTextEditorProvider(toExtensionData(extension), viewType, options, {
|
||||
supportsMove: !!provider.moveCustomTextEditor,
|
||||
});
|
||||
} else {
|
||||
disposables.add(this._editorProviders.addCustomProvider(viewType, extension, provider));
|
||||
this._proxy.$registerCustomEditorProvider(toExtensionData(extension), viewType, options);
|
||||
@@ -663,6 +665,26 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
|
||||
document._disposeEdits(editIds);
|
||||
}
|
||||
|
||||
async $onMoveCustomEditor(handle: string, newResourceComponents: UriComponents, viewType: string): Promise<void> {
|
||||
const entry = this._editorProviders.get(viewType);
|
||||
if (!entry) {
|
||||
throw new Error(`No provider found for '${viewType}'`);
|
||||
}
|
||||
|
||||
if (!(entry.provider as vscode.CustomTextEditorProvider).moveCustomTextEditor) {
|
||||
throw new Error(`Provider does not implement move '${viewType}'`);
|
||||
}
|
||||
|
||||
const webview = this.getWebviewPanel(handle);
|
||||
if (!webview) {
|
||||
throw new Error(`No webview found`);
|
||||
}
|
||||
|
||||
const resource = URI.revive(newResourceComponents);
|
||||
const document = this._extHostDocuments.getDocument(resource);
|
||||
await (entry.provider as vscode.CustomTextEditorProvider).moveCustomTextEditor!(document, webview);
|
||||
}
|
||||
|
||||
async $undo(resourceComponents: UriComponents, viewType: string, editId: number): Promise<void> {
|
||||
const document = this.getCustomDocument(viewType, resourceComponents);
|
||||
return document._undo(editId);
|
||||
|
||||
@@ -61,7 +61,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
|
||||
// Do this when extension service exists, but extensions are not being activated yet.
|
||||
const configProvider = await this._extHostConfiguration.getConfigProvider();
|
||||
await connectProxyResolver(this._extHostWorkspace, configProvider, this, this._logService, this._mainThreadTelemetryProxy);
|
||||
await connectProxyResolver(this._extHostWorkspace, configProvider, this, this._logService, this._mainThreadTelemetryProxy, this._initData);
|
||||
|
||||
// Use IPC messages to forward console-calls, note that the console is
|
||||
// already patched to use`process.send()`
|
||||
|
||||
Reference in New Issue
Block a user