diff --git a/src/vs/workbench/api/common/extHostTesting.ts b/src/vs/workbench/api/common/extHostTesting.ts index bf44c8939d4..e6f7569b906 100644 --- a/src/vs/workbench/api/common/extHostTesting.ts +++ b/src/vs/workbench/api/common/extHostTesting.ts @@ -23,7 +23,7 @@ import * as Convert from 'vs/workbench/api/common/extHostTypeConverters'; import { TestRunProfileKind, TestRunRequest } from 'vs/workbench/api/common/extHostTypes'; import { TestId, TestIdPathParts, TestPosition } from 'vs/workbench/contrib/testing/common/testId'; import { InvalidTestItemError } from 'vs/workbench/contrib/testing/common/testItemCollection'; -import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, RunTestForControllerRequest, RunTestForControllerResult, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; +import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, ITestItemContext, RunTestForControllerRequest, RunTestForControllerResult, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; import type * as vscode from 'vscode'; interface ControllerInfo { @@ -52,8 +52,16 @@ export class ExtHostTesting implements ExtHostTestingShape { this.runTracker = new TestRunCoordinator(this.proxy); commands.registerArgumentProcessor({ - processArgument: arg => - arg?.$mid === MarshalledId.TestItemContext ? toItemFromContext(arg) : arg, + processArgument: arg => { + if (arg?.$mid !== MarshalledId.TestItemContext) { + return arg; + } + + const cast = arg as ITestItemContext; + const targetTest = cast.tests[cast.tests.length - 1].item.extId; + const controller = this.controllers.get(TestId.root(targetTest)); + return controller?.collection.tree.get(targetTest)?.actual ?? toItemFromContext(arg); + } }); }