From c9cf92d7655dc745fedbae753b31f8ed974cee45 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Tue, 7 May 2024 07:57:23 -0700 Subject: [PATCH] testing: finalize TestRunRequest.preserveFocus API Closes #209491 --- .../workbench/api/common/extHost.api.impl.ts | 1 - src/vs/workbench/api/common/extHostTesting.ts | 4 +-- src/vs/workbench/api/common/extHostTypes.ts | 2 +- .../common/extensionsApiProposals.ts | 1 - src/vscode-dts/vscode.d.ts | 11 +++++++- .../vscode.proposed.testPreserveFocus.d.ts | 28 ------------------- 6 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 src/vscode-dts/vscode.proposed.testPreserveFocus.d.ts diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 4070489c54e218..59cf9f72e3db66 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -1679,7 +1679,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I LinkedEditingRanges: extHostTypes.LinkedEditingRanges, TestResultState: extHostTypes.TestResultState, TestRunRequest: extHostTypes.TestRunRequest, - TestRunRequest2: extHostTypes.TestRunRequest, TestMessage: extHostTypes.TestMessage, TestTag: extHostTypes.TestTag, TestRunProfileKind: extHostTypes.TestRunProfileKind, diff --git a/src/vs/workbench/api/common/extHostTesting.ts b/src/vs/workbench/api/common/extHostTesting.ts index 27d76030c61edd..44a28328eab1c6 100644 --- a/src/vs/workbench/api/common/extHostTesting.ts +++ b/src/vs/workbench/api/common/extHostTesting.ts @@ -210,7 +210,7 @@ export class ExtHostTesting extends Disposable implements ExtHostTestingShape { } await this.proxy.$runTests({ - preserveFocus: (req as vscode.TestRunRequest2).preserveFocus ?? true, + preserveFocus: req.preserveFocus ?? true, targets: [{ testIds: req.include?.map(t => TestId.fromExtHostTestItem(t, controller.collection.root.id).toString()) ?? [controller.collection.root.id], profileGroup: profileGroupToBitset[profile.kind], @@ -746,7 +746,7 @@ export class TestRunCoordinator { exclude: request.exclude?.map(t => TestId.fromExtHostTestItem(t, collection.root.id).toString()) ?? [], id: dto.id, include: request.include?.map(t => TestId.fromExtHostTestItem(t, collection.root.id).toString()) ?? [collection.root.id], - preserveFocus: (request as vscode.TestRunRequest2).preserveFocus ?? true, + preserveFocus: request.preserveFocus ?? true, persist }); diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index c52e1c26cc210f..30b856317f86b0 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -4023,7 +4023,7 @@ export enum TestRunProfileKind { } @es5ClassCompat -export class TestRunRequest implements vscode.TestRunRequest2 { +export class TestRunRequest implements vscode.TestRunRequest { constructor( public readonly include: vscode.TestItem[] | undefined = undefined, public readonly exclude: vscode.TestItem[] | undefined = undefined, diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 0cbeb156a4c46f..2ee7867c7c52d1 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -117,7 +117,6 @@ export const allApiProposals = Object.freeze({ terminalSelection: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalSelection.d.ts', terminalShellIntegration: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalShellIntegration.d.ts', testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts', - testPreserveFocus: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testPreserveFocus.d.ts', textSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts', timeline: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts', tokenInformation: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tokenInformation.d.ts', diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 5e46124e664726..41946ad4c0ddb8 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -17400,13 +17400,22 @@ declare module 'vscode' { */ readonly continuous?: boolean; + /** + * Controls how test Test Results view is focused. If true, the editor + * will keep the maintain the user's focus. If false, the editor will + * prefer to move focus into the Test Results view, although + * this may be configured by users. + */ + readonly preserveFocus: boolean; + /** * @param include Array of specific tests to run, or undefined to run all tests * @param exclude An array of tests to exclude from the run. * @param profile The run profile used for this request. * @param continuous Whether to run tests continuously as source changes. + * @param preserveFocus Whether to preserve the user's focus when the run is started */ - constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean); + constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean, preserveFocus?: boolean); } /** diff --git a/src/vscode-dts/vscode.proposed.testPreserveFocus.d.ts b/src/vscode-dts/vscode.proposed.testPreserveFocus.d.ts deleted file mode 100644 index 1404b4de0961c9..00000000000000 --- a/src/vscode-dts/vscode.proposed.testPreserveFocus.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare module 'vscode' { - - // See https://github.com/microsoft/vscode/issues/209491 - - export class TestRunRequest2 extends TestRunRequest { - /** - * Controls how test Test Results view is focused. If true, the editor - * will keep the maintain the user's focus. If false, the editor will - * prefer to move focus into the Test Results view, although - * this may be configured by users. - */ - readonly preserveFocus: boolean; - - /** - * @param include Array of specific tests to run, or undefined to run all tests - * @param exclude An array of tests to exclude from the run. - * @param profile The run profile used for this request. - * @param continuous Whether to run tests continuously as source changes. - * @param preserveFocus Whether to preserve the user's focus when the run is started - */ - constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean); - } -}