diff --git a/src/vs/workbench/api/common/extHostTestingPrivateApi.ts b/src/vs/workbench/api/common/extHostTestingPrivateApi.ts index 270de0bd118..26c7081cce3 100644 --- a/src/vs/workbench/api/common/extHostTestingPrivateApi.ts +++ b/src/vs/workbench/api/common/extHostTestingPrivateApi.ts @@ -95,7 +95,7 @@ const testItemPropAccessor = ( }; }; -type WritableProps = Pick; +type WritableProps = Pick; const strictEqualComparator = (a: T, b: T) => a === b; @@ -107,6 +107,7 @@ const propComparators: { [K in keyof Required]: (a: vscode.TestIt }, label: strictEqualComparator, description: strictEqualComparator, + sortText: strictEqualComparator, busy: strictEqualComparator, error: strictEqualComparator, canResolveChildren: strictEqualComparator, @@ -129,6 +130,7 @@ const makePropDescriptors = (api: IExtHostTestItemApi, label: string): { [K in k range: testItemPropAccessor(api, 'range', undefined, propComparators.range), label: testItemPropAccessor(api, 'label', label, propComparators.label), description: testItemPropAccessor(api, 'description', undefined, propComparators.description), + sortText: testItemPropAccessor(api, 'sortText', undefined, propComparators.sortText), canResolveChildren: testItemPropAccessor(api, 'canResolveChildren', false, propComparators.canResolveChildren), busy: testItemPropAccessor(api, 'busy', false, propComparators.busy), error: testItemPropAccessor(api, 'error', undefined, propComparators.error), @@ -268,6 +270,7 @@ export class TestItemImpl implements vscode.TestItem { public range!: vscode.Range | undefined; public description!: string | undefined; + public sortText!: string | undefined; public label!: string; public error!: string | vscode.MarkdownString; public busy!: boolean; diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 6fb55ff9b3f..0ee265cda6c 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -1725,6 +1725,7 @@ export namespace TestItem { tags: item.tags.map(t => TestTag.namespace(ctrlId, t.id)), range: Range.from(item.range) || null, description: item.description || null, + sortText: item.sortText || null, error: item.error ? (MarkdownString.fromStrict(item.error) || null) : null, }; } @@ -1745,6 +1746,7 @@ export namespace TestItem { canResolveChildren: false, busy: false, description: item.description || undefined, + sortText: item.sortText || undefined, }; } @@ -1753,6 +1755,7 @@ export namespace TestItem { const testItem = new TestItemImpl(testId.controllerId, testId.localId, item.label, URI.revive(item.uri)); testItem.range = Range.to(item.range || undefined); testItem.description = item.description || undefined; + testItem.sortText = item.sortText || undefined; return testItem; } diff --git a/src/vs/workbench/contrib/testing/browser/explorerProjections/index.ts b/src/vs/workbench/contrib/testing/browser/explorerProjections/index.ts index 9e7aec1b28e..2f62f353d6c 100644 --- a/src/vs/workbench/contrib/testing/browser/explorerProjections/index.ts +++ b/src/vs/workbench/contrib/testing/browser/explorerProjections/index.ts @@ -115,6 +115,10 @@ export class TestItemTreeElement implements IActionableTestTreeElement { return this.test.item.description; } + public get sortText() { + return this.test.item.sortText; + } + /** * Whether the node's test result is 'retired' -- from an outdated test run. */ diff --git a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts index 70b0698aaad..b0904c6d9fb 100644 --- a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts +++ b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts @@ -960,7 +960,7 @@ class TreeSorter implements ITreeSorter { } } - return a.label.localeCompare(b.label); + return (a.sortText || a.label).localeCompare((b.sortText || b.label)); } } diff --git a/src/vs/workbench/contrib/testing/common/testCollection.ts b/src/vs/workbench/contrib/testing/common/testCollection.ts index 2d32a1f2896..31a63d02817 100644 --- a/src/vs/workbench/contrib/testing/common/testCollection.ts +++ b/src/vs/workbench/contrib/testing/common/testCollection.ts @@ -162,6 +162,7 @@ export interface ITestItem { range: IRange | null; description: string | null; error: string | IMarkdownString | null; + sortText: string | null; } export const enum TestItemExpandState { diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index d873a57b74d..8e9ff6f817f 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -14801,6 +14801,12 @@ declare module 'vscode' { */ description?: string; + /** + * Optional sortText to sort the test items by. If sort text exists on a + * {@link TestItem} then it is used instead of {@link TestItem.label}. + */ + sortText?: string; + /** * Location of the test item in its {@link uri}. *