diff --git a/eslint.config.js b/eslint.config.js index 69a9a692433..ec79c24f295 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -253,7 +253,6 @@ export default tseslint.config( 'src/vs/platform/terminal/test/node/terminalEnvironment.test.ts', 'src/vs/workbench/api/browser/mainThreadChatSessions.ts', 'src/vs/workbench/api/browser/mainThreadDebugService.ts', - 'src/vs/workbench/api/browser/mainThreadTerminalService.ts', 'src/vs/workbench/api/browser/mainThreadTesting.ts', 'src/vs/workbench/api/common/extHost.api.impl.ts', 'src/vs/workbench/api/common/extHostChatAgents2.ts', @@ -263,7 +262,6 @@ export default tseslint.config( 'src/vs/workbench/api/common/extHostQuickOpen.ts', 'src/vs/workbench/api/common/extHostRequireInterceptor.ts', 'src/vs/workbench/api/common/extHostTelemetry.ts', - 'src/vs/workbench/api/common/extHostTerminalService.ts', 'src/vs/workbench/api/common/extHostTypeConverters.ts', 'src/vs/workbench/api/common/extHostTypes.ts', 'src/vs/workbench/api/node/loopbackServer.ts', diff --git a/src/vs/workbench/api/browser/mainThreadTerminalService.ts b/src/vs/workbench/api/browser/mainThreadTerminalService.ts index 28ed1215289..a8f901b9a7c 100644 --- a/src/vs/workbench/api/browser/mainThreadTerminalService.ts +++ b/src/vs/workbench/api/browser/mainThreadTerminalService.ts @@ -26,6 +26,7 @@ import { ITerminalQuickFixService, ITerminalQuickFix, TerminalQuickFixType } fro import { TerminalCapability } from '../../../platform/terminal/common/capabilities/capabilities.js'; import { ITerminalCompletionService } from '../../contrib/terminalContrib/suggest/browser/terminalCompletionService.js'; import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js'; +import { hasKey } from '../../../base/common/types.js'; @extHostNamedCustomer(MainContext.MainThreadTerminalService) export class MainThreadTerminalService implements MainThreadTerminalServiceShape { @@ -182,7 +183,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape } private async _deserializeParentTerminal(location?: TerminalLocation | TerminalEditorLocationOptions | { parentTerminal: ExtHostTerminalIdentifier } | { splitActiveTerminal: boolean; location?: TerminalLocation }): Promise { - if (typeof location === 'object' && 'parentTerminal' in location) { + if (typeof location === 'object' && hasKey(location, { parentTerminal: true })) { const parentTerminal = await this._extHostTerminals.get(location.parentTerminal.toString()); return parentTerminal ? { parentTerminal } : undefined; } @@ -527,10 +528,10 @@ export function getOutputMatchForLines(lines: string[], outputMatcher: ITerminal function parseQuickFix(id: string, source: string, fix: TerminalQuickFix): ITerminalQuickFix { let type = TerminalQuickFixType.TerminalCommand; - if ('uri' in fix) { + if (hasKey(fix, { uri: true })) { fix.uri = URI.revive(fix.uri); type = TerminalQuickFixType.Opener; - } else if ('id' in fix) { + } else if (hasKey(fix, { id: true })) { type = TerminalQuickFixType.VscodeCommand; } return { id, type, source, ...fix }; diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index effd94a2ce3..ce9a7667d6e 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -28,6 +28,7 @@ import { IExtHostCommands } from './extHostCommands.js'; import { MarshalledId } from '../../../base/common/marshallingIds.js'; import { ISerializedTerminalInstanceContext } from '../../contrib/terminal/common/terminal.js'; import { isWindows } from '../../../base/common/platform.js'; +import { hasKey } from '../../../base/common/types.js'; export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable { @@ -218,11 +219,11 @@ export class ExtHostTerminal extends Disposable { private _serializeParentTerminal(location?: TerminalLocation | vscode.TerminalEditorLocationOptions | vscode.TerminalSplitLocationOptions, parentTerminal?: ExtHostTerminalIdentifier): TerminalLocation | { viewColumn: EditorGroupColumn; preserveFocus?: boolean } | { parentTerminal: ExtHostTerminalIdentifier } | undefined { if (typeof location === 'object') { - if ('parentTerminal' in location && location.parentTerminal && parentTerminal) { + if (hasKey(location, { parentTerminal: true }) && location.parentTerminal && parentTerminal) { return { parentTerminal }; } - if ('viewColumn' in location) { + if (hasKey(location, { viewColumn: true })) { return { viewColumn: ViewColumn.from(location.viewColumn), preserveFocus: location.preserveFocus }; } @@ -527,7 +528,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I protected _serializeParentTerminal(options: vscode.TerminalOptions, internalOptions?: ITerminalInternalOptions): ITerminalInternalOptions { internalOptions = internalOptions ? internalOptions : {}; - if (options.location && typeof options.location === 'object' && 'parentTerminal' in options.location) { + if (options.location && typeof options.location === 'object' && hasKey(options.location, { parentTerminal: true })) { const parentTerminal = options.location.parentTerminal; if (parentTerminal) { const parentExtHostTerminal = this._terminals.find(t => t.value === parentTerminal); @@ -537,7 +538,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I } } else if (options.location && typeof options.location !== 'object') { internalOptions.location = options.location; - } else if (internalOptions.location && typeof internalOptions.location === 'object' && 'splitActiveTerminal' in internalOptions.location) { + } else if (internalOptions.location && typeof internalOptions.location === 'object' && hasKey(internalOptions.location, { splitActiveTerminal: true })) { internalOptions.location = { splitActiveTerminal: true }; } return internalOptions; @@ -850,15 +851,15 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I if (token.isCancellationRequested) { return; } - if (profile && !('options' in profile)) { + if (profile && !hasKey(profile, { options: true })) { profile = { options: profile }; } - if (!profile || !('options' in profile)) { + if (!profile || !hasKey(profile, { options: true })) { throw new Error(`No terminal profile options provided for id "${id}"`); } - if ('pty' in profile.options) { + if (hasKey(profile.options, { pty: true })) { this.createExtensionTerminal(profile.options, options); return; } @@ -1270,7 +1271,7 @@ function asTerminalIcon(iconPath?: vscode.Uri | { light: vscode.Uri; dark: vscod return undefined; } - if (!('id' in iconPath)) { + if (!hasKey(iconPath, { id: true })) { return iconPath; }