Merge branch 'microsoft:main' into main

This commit is contained in:
Simon McEnlly
2021-11-03 15:43:49 +10:00
committed by GitHub
310 changed files with 6300 additions and 5776 deletions

View File

@@ -138,7 +138,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
if (modified('range')) { this._range = changes.range!; }
if (modified('label')) { this._label = changes.label; }
if (modified('contextValue')) { this._contextValue = changes.contextValue; }
if (modified('contextValue')) { this._contextValue = changes.contextValue === null ? undefined : changes.contextValue; }
if (modified('comments')) { this._comments = changes.comments; }
if (modified('collapseState')) { this._collapsibleState = changes.collapseState; }
if (modified('canReply')) { this.canReply = changes.canReply!; }

View File

@@ -10,13 +10,13 @@ import { URI } from 'vs/base/common/uri';
import { StopWatch } from 'vs/base/common/stopwatch';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensions, TerminalLocation, TitleEventSource } from 'vs/platform/terminal/common/terminal';
import { IProcessProperty, IShellLaunchConfig, IShellLaunchConfigDto, ProcessPropertyType, TerminalLocation, TitleEventSource } from 'vs/platform/terminal/common/terminal';
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
import { ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroupService, ITerminalInstance, ITerminalInstanceService, ITerminalLink, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy';
import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
import { deserializeEnvironmentVariableCollection, serializeEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariableShared';
import { IStartExtensionTerminalRequest, ITerminalProcessExtHostProxy, ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
import { IStartExtensionTerminalRequest, ITerminalProcessExtHostProxy, ITerminalProfileResolverService, ITerminalProfileService } from 'vs/workbench/contrib/terminal/common/terminal';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { withNullAsUndefined } from 'vs/base/common/types';
import { OperatingSystem, OS } from 'vs/base/common/platform';
@@ -57,7 +57,8 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
@ITerminalProfileResolverService private readonly _terminalProfileResolverService: ITerminalProfileResolverService,
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@ITerminalGroupService private readonly _terminalGroupService: ITerminalGroupService,
@ITerminalEditorService private readonly _terminalEditorService: ITerminalEditorService
@ITerminalEditorService private readonly _terminalEditorService: ITerminalEditorService,
@ITerminalProfileService private readonly _terminalProfileService: ITerminalProfileService
) {
this._proxy = _extHostContext.getProxy(ExtHostContext.ExtHostTerminalService);
@@ -97,7 +98,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._os = env?.os || OS;
this._updateDefaultProfile();
});
this._terminalService.onDidChangeAvailableProfiles(() => this._updateDefaultProfile());
this._terminalProfileService.onDidChangeAvailableProfiles(() => this._updateDefaultProfile());
}
public dispose(): void {
@@ -141,8 +142,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
isExtensionOwnedTerminal: launchConfig.isExtensionOwnedTerminal,
useShellEnvironment: launchConfig.useShellEnvironment,
};
// eslint-disable-next-line no-async-promise-executor
const terminal = Promises.withAsyncBody<ITerminalInstance>(async r => {
const terminal = await this._terminalService.createTerminal({
config: shellLaunchConfig,
@@ -191,6 +190,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
await instance?.sendText(text, addNewLine);
}
public $sendProcessExit(terminalId: number, exitCode: number | undefined): void {
this._terminalProcessProxies.get(terminalId)?.emitExit(exitCode);
}
public $startSendingDataEvents(): void {
if (!this._dataEventTracker) {
this._dataEventTracker = this._instantiationService.createInstance(TerminalDataEventTracker, (id, data) => {
@@ -224,7 +227,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
public $registerProfileProvider(id: string, extensionIdentifier: string): void {
// Proxy profile provider requests through the extension host
this._profileProviders.set(id, this._terminalService.registerTerminalProfileProvider(extensionIdentifier, id, {
this._profileProviders.set(id, this._terminalProfileService.registerTerminalProfileProvider(extensionIdentifier, id, {
createContributedTerminalProfile: async (options) => {
return this._proxy.$createContributedProfileTerminal(id, options);
}
@@ -303,18 +306,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
proxy.onRequestLatency(() => this._onRequestLatency(proxy.instanceId));
}
public $sendProcessTitle(terminalId: number, title: string): void {
// Since title events can only come from vscode.Pseudoterminals right now, these are routed
// directly to the instance as API source events such that they will replace the initial
// `name` property provided for the Pseudoterminal. If we support showing both Api and
// Process titles at the same time we may want to pass this through as a Process source
// event.
const instance = this._terminalService.getInstanceFromId(terminalId);
if (instance) {
instance.refreshTabLabels(title, TitleEventSource.Api);
}
}
public $sendProcessData(terminalId: number, data: string): void {
this._terminalProcessProxies.get(terminalId)?.emitData(data);
}
@@ -323,24 +314,14 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._terminalProcessProxies.get(terminalId)?.emitReady(pid, cwd);
}
public $sendProcessExit(terminalId: number, exitCode: number | undefined): void {
this._terminalProcessProxies.get(terminalId)?.emitExit(exitCode);
}
public $sendOverrideDimensions(terminalId: number, dimensions: ITerminalDimensions | undefined): void {
this._terminalProcessProxies.get(terminalId)?.emitOverrideDimensions(dimensions);
}
public $sendProcessInitialCwd(terminalId: number, initialCwd: string): void {
this._terminalProcessProxies.get(terminalId)?.emitInitialCwd(initialCwd);
}
public $sendProcessCwd(terminalId: number, cwd: string): void {
this._terminalProcessProxies.get(terminalId)?.emitCwd(cwd);
}
public $sendResolvedLaunchConfig(terminalId: number, shellLaunchConfig: IShellLaunchConfig): void {
this._getTerminalProcess(terminalId)?.emitResolvedShellLaunchConfig(shellLaunchConfig);
public $sendProcessProperty(terminalId: number, property: IProcessProperty<any>): void {
if (property.type === ProcessPropertyType.Title) {
const instance = this._terminalService.getInstanceFromId(terminalId);
if (instance) {
instance.refreshTabLabels(property.value, TitleEventSource.Api);
}
}
this._terminalProcessProxies.get(terminalId)?.emitProcessProperty(property);
}
private async _onRequestLatency(terminalId: number): Promise<void> {

View File

@@ -39,7 +39,7 @@ import { IRemoteConnectionData, RemoteAuthorityResolverErrorCode, ResolverResult
import { ProvidedPortAttributes, TunnelCreationOptions, TunnelOptions, TunnelProviderFeatures } from 'vs/platform/remote/common/tunnel';
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
import { ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { ICreateContributedTerminalProfileOptions, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensions, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, TerminalLocation } from 'vs/platform/terminal/common/terminal';
import { ICreateContributedTerminalProfileOptions, IProcessProperty, IShellLaunchConfigDto, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, TerminalLocation } from 'vs/platform/terminal/common/terminal';
import { ThemeColor, ThemeIcon } from 'vs/platform/theme/common/themeService';
import { IExtensionIdWithVersion } from 'vs/platform/userDataSync/common/extensionsStorageSync';
import { WorkspaceTrustRequestOptions } from 'vs/platform/workspace/common/workspaceTrust';
@@ -154,7 +154,7 @@ export interface CommentProviderFeatures {
export type CommentThreadChanges = Partial<{
range: IRange,
label: string,
contextValue: string,
contextValue: string | null,
comments: modes.Comment[],
collapseState: modes.CommentThreadCollapsibleState;
canReply: boolean;
@@ -505,14 +505,10 @@ export interface MainThreadTerminalServiceShape extends IDisposable {
$setEnvironmentVariableCollection(extensionIdentifier: string, persistent: boolean, collection: ISerializableEnvironmentVariableCollection | undefined): void;
// Process
$sendProcessTitle(terminalId: number, title: string): void;
$sendProcessData(terminalId: number, data: string): void;
$sendProcessReady(terminalId: number, pid: number, cwd: string): void;
$sendProcessProperty(terminalId: number, property: IProcessProperty<any>): void;
$sendProcessExit(terminalId: number, exitCode: number | undefined): void;
$sendProcessInitialCwd(terminalId: number, cwd: string): void;
$sendProcessCwd(terminalId: number, initialCwd: string): void;
$sendOverrideDimensions(terminalId: number, dimensions: ITerminalDimensions | undefined): void;
$sendResolvedLaunchConfig(terminalId: number, shellLaunchConfig: IShellLaunchConfig): void;
}
export interface TransferQuickPickItems extends quickInput.IQuickPickItem {

View File

@@ -425,7 +425,11 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
formattedModifications.label = this.label;
}
if (modified('contextValue')) {
formattedModifications.contextValue = this.contextValue;
/*
* null -> cleared contextValue
* undefined -> no change
*/
formattedModifications.contextValue = this.contextValue ?? null;
}
if (modified('comments')) {
formattedModifications.comments =

View File

@@ -42,8 +42,8 @@ export class ExtHostNotebookConcatDocument implements vscode.NotebookConcatTextD
this._disposables.add(extHostDocuments.onDidChangeDocument(e => {
const cellIdx = this._cellUris.get(e.document.uri);
if (cellIdx !== undefined) {
this._cellLengths.changeValue(cellIdx, this._cells[cellIdx].document.getText().length + 1);
this._cellLines.changeValue(cellIdx, this._cells[cellIdx].document.lineCount);
this._cellLengths.setValue(cellIdx, this._cells[cellIdx].document.getText().length + 1);
this._cellLines.setValue(cellIdx, this._cells[cellIdx].document.lineCount);
this._versionId += 1;
this._onDidChange.fire(undefined);
}

View File

@@ -492,10 +492,6 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition: tasks.TaskDefinitionDTO): Promise<void> {
const customExecution: types.CustomExecution | undefined = this._providedCustomExecutions2.get(execution.id);
if (customExecution) {
if (this._activeCustomExecutions2.get(execution.id) !== undefined) {
throw new Error('We should not be trying to start the same custom task executions twice.');
}
// Clone the custom execution to keep the original untouched. This is important for multiple runs of the same task.
this._activeCustomExecutions2.set(execution.id, customExecution);
this._terminalService.attachPtyToTerminal(terminalId, await customExecution.callback(resolvedDefinition));
@@ -625,6 +621,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
const taskId = await this._proxy.$createTaskId(taskDTO);
if (!isProvided && !this._providedCustomExecutions2.has(taskId)) {
this._notProvidedCustomExecutions.add(taskId);
// Also add to active executions when not coming from a provider to prevent timing issue.
this._activeCustomExecutions2.set(taskId, <types.CustomExecution>task.execution);
}
this._providedCustomExecutions2.set(taskId, <types.CustomExecution>task.execution);
}
@@ -642,13 +640,20 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
if (result) {
return result;
}
// eslint-disable-next-line no-async-promise-executor
const createdResult: Promise<TaskExecutionImpl> = new Promise(async (resolve, reject) => {
const taskToCreate = task ? task : await TaskDTO.to(execution.task, this._workspaceProvider, this._providedCustomExecutions2);
if (!taskToCreate) {
reject('Unexpected: Task does not exist.');
const createdResult: Promise<TaskExecutionImpl> = new Promise((resolve, reject) => {
function resolvePromiseWithCreatedTask(that: ExtHostTaskBase, execution: tasks.TaskExecutionDTO, taskToCreate: vscode.Task | types.Task | undefined) {
if (!taskToCreate) {
reject('Unexpected: Task does not exist.');
} else {
resolve(new TaskExecutionImpl(that, execution.id, taskToCreate));
}
}
if (task) {
resolvePromiseWithCreatedTask(this, execution, task);
} else {
resolve(new TaskExecutionImpl(this, execution.id, taskToCreate));
TaskDTO.to(execution.task, this._workspaceProvider, this._providedCustomExecutions2)
.then(task => resolvePromiseWithCreatedTask(this, execution, task));
}
});

View File

@@ -18,7 +18,7 @@ import { serializeEnvironmentVariableCollection } from 'vs/workbench/contrib/ter
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { generateUuid } from 'vs/base/common/uuid';
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, TerminalShellType, IShellLaunchConfig, ProcessPropertyType, ProcessCapability, IProcessPropertyMap } from 'vs/platform/terminal/common/terminal';
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, ProcessPropertyType, ProcessCapability, IProcessPropertyMap } from 'vs/platform/terminal/common/terminal';
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
import { withNullAsUndefined } from 'vs/base/common/types';
@@ -249,30 +249,21 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
get capabilities(): ProcessCapability[] { return this._capabilities; }
private readonly _onProcessData = new Emitter<string>();
public readonly onProcessData: Event<string> = this._onProcessData.event;
private readonly _onProcessExit = new Emitter<number | undefined>();
public readonly onProcessExit: Event<number | undefined> = this._onProcessExit.event;
private readonly _onProcessReady = new Emitter<IProcessReadyEvent>();
public get onProcessReady(): Event<IProcessReadyEvent> { return this._onProcessReady.event; }
private readonly _onProcessTitleChanged = new Emitter<string>();
public readonly onProcessTitleChanged: Event<string> = this._onProcessTitleChanged.event;
private readonly _onProcessOverrideDimensions = new Emitter<ITerminalDimensionsOverride | undefined>();
public get onProcessOverrideDimensions(): Event<ITerminalDimensionsOverride | undefined> { return this._onProcessOverrideDimensions.event; }
private readonly _onProcessShellTypeChanged = new Emitter<TerminalShellType>();
public readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event;
private readonly _onDidChangeProperty = new Emitter<IProcessProperty<any>>();
public readonly onDidChangeProperty = this._onDidChangeProperty.event;
private readonly _onProcessExit = new Emitter<number | undefined>();
public readonly onProcessExit: Event<number | undefined> = this._onProcessExit.event;
constructor(private readonly _pty: vscode.Pseudoterminal) { }
onProcessResolvedShellLaunchConfig?: Event<IShellLaunchConfig> | undefined;
onDidChangeHasChildProcesses?: Event<boolean> | undefined;
refreshProperty<T extends ProcessPropertyType>(property: ProcessPropertyType): Promise<IProcessPropertyMap[T]> {
return Promise.resolve('');
throw new Error(`refreshProperty is not suppported in extension owned terminals. property: ${property}`);
}
async updateProperty<T extends ProcessPropertyType>(property: ProcessPropertyType, value: IProcessPropertyMap[T]): Promise<void> {
Promise.resolve('');
updateProperty<T extends ProcessPropertyType>(property: ProcessPropertyType, value: IProcessPropertyMap[T]): Promise<void> {
throw new Error(`updateProperty is not suppported in extension owned terminals. property: ${property}, value: ${value}`);
}
async start(): Promise<undefined> {
@@ -329,10 +320,16 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
});
}
if (this._pty.onDidOverrideDimensions) {
this._pty.onDidOverrideDimensions(e => this._onProcessOverrideDimensions.fire(e ? { cols: e.columns, rows: e.rows } : e));
this._pty.onDidOverrideDimensions(e => {
if (e) {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.OverrideDimensions, value: { cols: e.columns, rows: e.rows } });
}
});
}
if (this._pty.onDidChangeName) {
this._pty.onDidChangeName(title => this._onProcessTitleChanged.fire(title));
this._pty.onDidChangeName(title => {
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Title, value: title });
});
}
this._pty.open(initialDimensions ? initialDimensions : undefined);
@@ -589,17 +586,12 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
protected _setupExtHostProcessListeners(id: number, p: ITerminalChildProcess): IDisposable {
const disposables = new DisposableStore();
disposables.add(p.onProcessReady((e: { pid: number, cwd: string }) => this._proxy.$sendProcessReady(id, e.pid, e.cwd)));
disposables.add(p.onProcessTitleChanged(title => this._proxy.$sendProcessTitle(id, title)));
disposables.add(p.onDidChangeProperty(property => this._proxy.$sendProcessProperty(id, property)));
// Buffer data events to reduce the amount of messages going to the renderer
this._bufferer.startBuffering(id, p.onProcessData);
disposables.add(p.onProcessExit(exitCode => this._onProcessExit(id, exitCode)));
if (p.onProcessOverrideDimensions) {
disposables.add(p.onProcessOverrideDimensions(e => this._proxy.$sendOverrideDimensions(id, e)));
}
this._terminalProcesses.set(id, p);
const awaitingStart = this._extensionTerminalAwaitingStart[id];
@@ -642,11 +634,11 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
}
public $acceptProcessRequestInitialCwd(id: number): void {
this._terminalProcesses.get(id)?.getInitialCwd().then(initialCwd => this._proxy.$sendProcessInitialCwd(id, initialCwd));
this._terminalProcesses.get(id)?.getInitialCwd().then(initialCwd => this._proxy.$sendProcessProperty(id, { type: ProcessPropertyType.InitialCwd, value: initialCwd }));
}
public $acceptProcessRequestCwd(id: number): void {
this._terminalProcesses.get(id)?.getCwd().then(cwd => this._proxy.$sendProcessCwd(id, cwd));
this._terminalProcesses.get(id)?.getCwd().then(cwd => this._proxy.$sendProcessProperty(id, { type: ProcessPropertyType.Cwd, value: cwd }));
}
public $acceptProcessRequestLatency(id: number): number {
@@ -777,7 +769,6 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
processDiposable.dispose();
delete this._terminalProcessDisposables[id];
}
// Send exit event to main side
this._proxy.$sendProcessExit(id, exitCode);
}