Merge pull request #276271 from microsoft/tyriar/274723_platform_terminal__api

Remove any from terminal in api/, services/
This commit is contained in:
Daniel Imms
2025-11-10 07:49:31 -08:00
committed by GitHub
5 changed files with 22 additions and 28 deletions

View File

@@ -599,7 +599,6 @@ export default tseslint.config(
'src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/utils/utils.ts', 'src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/utils/utils.ts',
// Workbench // Workbench
'src/vs/workbench/api/browser/mainThreadChatSessions.ts', 'src/vs/workbench/api/browser/mainThreadChatSessions.ts',
'src/vs/workbench/api/browser/mainThreadTerminalService.ts',
'src/vs/workbench/api/common/configurationExtensionPoint.ts', 'src/vs/workbench/api/common/configurationExtensionPoint.ts',
'src/vs/workbench/api/common/extHost.api.impl.ts', 'src/vs/workbench/api/common/extHost.api.impl.ts',
'src/vs/workbench/api/common/extHost.protocol.ts', 'src/vs/workbench/api/common/extHost.protocol.ts',
@@ -629,7 +628,6 @@ export default tseslint.config(
'src/vs/workbench/api/common/extHostStatusBar.ts', 'src/vs/workbench/api/common/extHostStatusBar.ts',
'src/vs/workbench/api/common/extHostStoragePaths.ts', 'src/vs/workbench/api/common/extHostStoragePaths.ts',
'src/vs/workbench/api/common/extHostTelemetry.ts', 'src/vs/workbench/api/common/extHostTelemetry.ts',
'src/vs/workbench/api/common/extHostTerminalService.ts',
'src/vs/workbench/api/common/extHostTesting.ts', 'src/vs/workbench/api/common/extHostTesting.ts',
'src/vs/workbench/api/common/extHostTextEditor.ts', 'src/vs/workbench/api/common/extHostTextEditor.ts',
'src/vs/workbench/api/common/extHostTimeline.ts', 'src/vs/workbench/api/common/extHostTimeline.ts',
@@ -898,7 +896,6 @@ export default tseslint.config(
'src/vs/workbench/services/search/node/fileSearch.ts', 'src/vs/workbench/services/search/node/fileSearch.ts',
'src/vs/workbench/services/search/node/rawSearchService.ts', 'src/vs/workbench/services/search/node/rawSearchService.ts',
'src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts', 'src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts',
'src/vs/workbench/services/terminal/common/embedderTerminalService.ts',
'src/vs/workbench/services/textMate/common/TMGrammarFactory.ts', 'src/vs/workbench/services/textMate/common/TMGrammarFactory.ts',
'src/vs/workbench/services/themes/browser/fileIconThemeData.ts', 'src/vs/workbench/services/themes/browser/fileIconThemeData.ts',
'src/vs/workbench/services/themes/browser/productIconThemeData.ts', 'src/vs/workbench/services/themes/browser/productIconThemeData.ts',

View File

@@ -926,16 +926,16 @@ import { assertNoRpc, poll } from '../utils';
applyAtProcessCreation: true, applyAtProcessCreation: true,
applyAtShellIntegration: false applyAtShellIntegration: false
}; };
deepStrictEqual(collection.get('A'), { value: '~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions }); deepStrictEqual(collection.get('A'), { value: '~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions, variable: 'A' });
deepStrictEqual(collection.get('B'), { value: '~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions }); deepStrictEqual(collection.get('B'), { value: '~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions, variable: 'B' });
deepStrictEqual(collection.get('C'), { value: '~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions }); deepStrictEqual(collection.get('C'), { value: '~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions, variable: 'C' });
// Verify forEach // Verify forEach
const entries: [string, EnvironmentVariableMutator][] = []; const entries: [string, EnvironmentVariableMutator][] = [];
collection.forEach((v, m) => entries.push([v, m])); collection.forEach((v, m) => entries.push([v, m]));
deepStrictEqual(entries, [ deepStrictEqual(entries, [
['A', { value: '~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions }], ['A', { value: '~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions, variable: 'A' }],
['B', { value: '~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions }], ['B', { value: '~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions, variable: 'B' }],
['C', { value: '~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions }] ['C', { value: '~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions, variable: 'C' }]
]); ]);
}); });
@@ -956,17 +956,17 @@ import { assertNoRpc, poll } from '../utils';
applyAtShellIntegration: false applyAtShellIntegration: false
}; };
const expectedScopedCollection = collection.getScoped(scope); const expectedScopedCollection = collection.getScoped(scope);
deepStrictEqual(expectedScopedCollection.get('A'), { value: 'scoped~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions }); deepStrictEqual(expectedScopedCollection.get('A'), { value: 'scoped~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions, variable: 'A' });
deepStrictEqual(expectedScopedCollection.get('B'), { value: 'scoped~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions }); deepStrictEqual(expectedScopedCollection.get('B'), { value: 'scoped~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions, variable: 'B' });
deepStrictEqual(expectedScopedCollection.get('C'), { value: 'scoped~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions }); deepStrictEqual(expectedScopedCollection.get('C'), { value: 'scoped~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions, variable: 'C' });
// Verify forEach // Verify forEach
const entries: [string, EnvironmentVariableMutator][] = []; const entries: [string, EnvironmentVariableMutator][] = [];
expectedScopedCollection.forEach((v, m) => entries.push([v, m])); expectedScopedCollection.forEach((v, m) => entries.push([v, m]));
deepStrictEqual(entries.map(v => v[1]), [ deepStrictEqual(entries.map(v => v[1]), [
{ value: 'scoped~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions }, { value: 'scoped~a2~', type: EnvironmentVariableMutatorType.Replace, options: defaultOptions, variable: 'A' },
{ value: 'scoped~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions }, { value: 'scoped~b2~', type: EnvironmentVariableMutatorType.Append, options: defaultOptions, variable: 'B' },
{ value: 'scoped~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions } { value: 'scoped~c2~', type: EnvironmentVariableMutatorType.Prepend, options: defaultOptions, variable: 'C' }
]); ]);
deepStrictEqual(entries.map(v => v[0]), ['A', 'B', 'C']); deepStrictEqual(entries.map(v => v[0]), ['A', 'B', 'C']);
}); });

View File

@@ -9,7 +9,7 @@ import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions
import { URI } from '../../../base/common/uri.js'; import { URI } from '../../../base/common/uri.js';
import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js'; import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
import { ILogService } from '../../../platform/log/common/log.js'; import { ILogService } from '../../../platform/log/common/log.js';
import { IProcessProperty, IProcessReadyWindowsPty, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalOutputMatch, ITerminalOutputMatcher, ProcessPropertyType, TerminalExitReason, TerminalLocation } from '../../../platform/terminal/common/terminal.js'; import { IProcessProperty, IProcessReadyWindowsPty, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalOutputMatch, ITerminalOutputMatcher, ProcessPropertyType, TerminalExitReason, TerminalLocation, type IProcessPropertyMap } from '../../../platform/terminal/common/terminal.js';
import { TerminalDataBufferer } from '../../../platform/terminal/common/terminalDataBuffering.js'; import { TerminalDataBufferer } from '../../../platform/terminal/common/terminalDataBuffering.js';
import { ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroupService, ITerminalInstance, ITerminalLink, ITerminalService } from '../../contrib/terminal/browser/terminal.js'; import { ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroupService, ITerminalInstance, ITerminalLink, ITerminalService } from '../../contrib/terminal/browser/terminal.js';
import { TerminalProcessExtHostProxy } from '../../contrib/terminal/browser/terminalProcessExtHostProxy.js'; import { TerminalProcessExtHostProxy } from '../../contrib/terminal/browser/terminalProcessExtHostProxy.js';
@@ -452,10 +452,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._terminalProcessProxies.get(terminalId)?.emitReady(pid, cwd, windowsPty); this._terminalProcessProxies.get(terminalId)?.emitReady(pid, cwd, windowsPty);
} }
public $sendProcessProperty(terminalId: number, property: IProcessProperty<any>): void { public $sendProcessProperty(terminalId: number, property: IProcessProperty): void {
if (property.type === ProcessPropertyType.Title) { if (property.type === ProcessPropertyType.Title) {
const instance = this._terminalService.getInstanceFromId(terminalId); const instance = this._terminalService.getInstanceFromId(terminalId);
instance?.rename(property.value); instance?.rename(property.value as IProcessPropertyMap[ProcessPropertyType.Title]);
} }
this._terminalProcessProxies.get(terminalId)?.emitProcessProperty(property); this._terminalProcessProxies.get(terminalId)?.emitProcessProperty(property);
} }

View File

@@ -84,7 +84,7 @@ export class ExtHostTerminal extends Disposable {
private _disposed: boolean = false; private _disposed: boolean = false;
private _pidPromise: Promise<number | undefined>; private _pidPromise: Promise<number | undefined>;
private _cols: number | undefined; private _cols: number | undefined;
private _pidPromiseComplete: ((value: number | undefined) => any) | undefined; private _pidPromiseComplete: ((value: number | undefined) => unknown) | undefined;
private _rows: number | undefined; private _rows: number | undefined;
private _exitStatus: vscode.TerminalExitStatus | undefined; private _exitStatus: vscode.TerminalExitStatus | undefined;
private _state: vscode.TerminalState = { isInteractedWith: false, shell: undefined }; private _state: vscode.TerminalState = { isInteractedWith: false, shell: undefined };
@@ -311,7 +311,7 @@ class ExtHostPseudoterminal implements ITerminalChildProcess {
public readonly onProcessData: Event<string> = this._onProcessData.event; public readonly onProcessData: Event<string> = this._onProcessData.event;
private readonly _onProcessReady = new Emitter<IProcessReadyEvent>(); private readonly _onProcessReady = new Emitter<IProcessReadyEvent>();
public get onProcessReady(): Event<IProcessReadyEvent> { return this._onProcessReady.event; } public get onProcessReady(): Event<IProcessReadyEvent> { return this._onProcessReady.event; }
private readonly _onDidChangeProperty = new Emitter<IProcessProperty<any>>(); private readonly _onDidChangeProperty = new Emitter<IProcessProperty>();
public readonly onDidChangeProperty = this._onDidChangeProperty.event; public readonly onDidChangeProperty = this._onDidChangeProperty.event;
private readonly _onProcessExit = new Emitter<number | undefined>(); private readonly _onProcessExit = new Emitter<number | undefined>();
public readonly onProcessExit: Event<number | undefined> = this._onProcessExit.event; public readonly onProcessExit: Event<number | undefined> = this._onProcessExit.event;
@@ -470,9 +470,8 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
this._proxy.$registerProcessSupport(supportsProcesses); this._proxy.$registerProcessSupport(supportsProcesses);
this._extHostCommands.registerArgumentProcessor({ this._extHostCommands.registerArgumentProcessor({
processArgument: arg => { processArgument: arg => {
const deserialize = (arg: any) => { const deserialize = (arg: ISerializedTerminalInstanceContext) => {
const cast = arg as ISerializedTerminalInstanceContext; return this.getTerminalById(arg.instanceId)?.value;
return this.getTerminalById(cast.instanceId)?.value;
}; };
switch (arg?.$mid) { switch (arg?.$mid) {
case MarshalledId.TerminalContext: return deserialize(arg); case MarshalledId.TerminalContext: return deserialize(arg);
@@ -1223,7 +1222,7 @@ class ScopedEnvironmentVariableCollection implements IEnvironmentVariableCollect
return this.collection.get(variable, this.scope); return this.collection.get(variable, this.scope);
} }
forEach(callback: (variable: string, mutator: vscode.EnvironmentVariableMutator, collection: vscode.EnvironmentVariableCollection) => any, thisArg?: any): void { forEach(callback: (variable: string, mutator: vscode.EnvironmentVariableMutator, collection: vscode.EnvironmentVariableCollection) => unknown, thisArg?: unknown): void {
this.collection.getVariableMap(this.scope).forEach((value, variable) => callback.call(thisArg, variable, value, this), this.scope); this.collection.getVariableMap(this.scope).forEach((value, variable) => callback.call(thisArg, variable, value, this), this.scope);
} }
@@ -1289,7 +1288,5 @@ function convertMutator(mutator: IEnvironmentVariableMutator): vscode.Environmen
const newMutator = { ...mutator }; const newMutator = { ...mutator };
delete newMutator.scope; delete newMutator.scope;
newMutator.options = newMutator.options ?? undefined; newMutator.options = newMutator.options ?? undefined;
// eslint-disable-next-line local/code-no-any-casts
delete (newMutator as any).variable;
return newMutator as vscode.EnvironmentVariableMutator; return newMutator as vscode.EnvironmentVariableMutator;
} }

View File

@@ -79,7 +79,7 @@ class EmbedderTerminalProcess extends Disposable implements ITerminalChildProces
readonly onProcessData: Event<IProcessDataEvent | string>; readonly onProcessData: Event<IProcessDataEvent | string>;
private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>()); private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>());
readonly onProcessReady = this._onProcessReady.event; readonly onProcessReady = this._onProcessReady.event;
private readonly _onDidChangeProperty = this._register(new Emitter<IProcessProperty<any>>()); private readonly _onDidChangeProperty = this._register(new Emitter<IProcessProperty>());
readonly onDidChangeProperty = this._onDidChangeProperty.event; readonly onDidChangeProperty = this._onDidChangeProperty.event;
private readonly _onProcessExit = this._register(new Emitter<number | undefined>()); private readonly _onProcessExit = this._register(new Emitter<number | undefined>());
readonly onProcessExit = this._onProcessExit.event; readonly onProcessExit = this._onProcessExit.event;
@@ -149,7 +149,7 @@ class EmbedderTerminalProcess extends Disposable implements ITerminalChildProces
throw new Error(`refreshProperty is not suppported in EmbedderTerminalProcess. property: ${property}`); throw new Error(`refreshProperty is not suppported in EmbedderTerminalProcess. property: ${property}`);
} }
updateProperty(property: ProcessPropertyType, value: any): Promise<void> { updateProperty(property: ProcessPropertyType, value: unknown): Promise<void> {
throw new Error(`updateProperty is not suppported in EmbedderTerminalProcess. property: ${property}, value: ${value}`); throw new Error(`updateProperty is not suppported in EmbedderTerminalProcess. property: ${property}, value: ${value}`);
} }
} }