From 24ae09b60e1a9e84f03aef65eb97b2bb554c84d1 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 29 Jul 2021 12:42:46 -0700 Subject: [PATCH] testing: fix test document filter not working with parent dirs on windows For #128824 --- .../contrib/testing/browser/testingExplorerView.ts | 10 +++++----- src/vs/workbench/contrib/testing/common/testService.ts | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts index a7deaf7a103..52000033939 100644 --- a/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts +++ b/src/vs/workbench/contrib/testing/browser/testingExplorerView.ts @@ -737,8 +737,8 @@ const enum FilterResult { Include, } -const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: URI | string, fromNode?: string) => { - testUri = testUri.toString(); +const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: URI, fromNode?: string) => { + const fsPath = testUri.fsPath; const queue: Iterable[] = [fromNode ? [fromNode] : collection.rootIds]; while (queue.length) { @@ -753,7 +753,7 @@ const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: continue; } - if (extpath.isEqualOrParent(testUri, node.item.uri.toString())) { + if (extpath.isEqualOrParent(fsPath, node.item.uri.fsPath)) { return true; } } @@ -765,7 +765,7 @@ const hasNodeInOrParentOfUri = (collection: IMainThreadTestCollection, testUri: class TestsFilter implements ITreeFilter { private lastText?: string; private filters: [include: boolean, value: string][] | undefined; - private documentUri: string | undefined; + private documentUri: URI | undefined; constructor( private readonly collection: IMainThreadTestCollection, @@ -826,7 +826,7 @@ class TestsFilter implements ITreeFilter { } public filterToDocumentUri(uri: URI | undefined) { - this.documentUri = uri?.toString(); + this.documentUri = uri; } private testState(element: TestItemTreeElement): FilterResult { diff --git a/src/vs/workbench/contrib/testing/common/testService.ts b/src/vs/workbench/contrib/testing/common/testService.ts index 14a9caf80e5..e339ac05aa4 100644 --- a/src/vs/workbench/contrib/testing/common/testService.ts +++ b/src/vs/workbench/contrib/testing/common/testService.ts @@ -161,18 +161,18 @@ export const getAllTestsInHierarchy = async (collection: IMainThreadTestCollecti * in strictly descending order. */ export const testsInFile = async function* (collection: IMainThreadTestCollection, uri: URI): AsyncIterable { - const demandUriStr = uri.toString(); + const demandFsPath = uri.fsPath; for (const test of collection.all) { if (!test.item.uri) { continue; } - const itemUriStr = test.item.uri.toString(); - if (itemUriStr === demandUriStr) { + const itemFsPath = test.item.uri.fsPath; + if (itemFsPath === demandFsPath) { yield test; } - if (extpath.isEqualOrParent(demandUriStr, itemUriStr) && test.expand === TestItemExpandState.Expandable) { + if (extpath.isEqualOrParent(demandFsPath, itemFsPath) && test.expand === TestItemExpandState.Expandable) { await collection.expand(test.item.extId, 1); } }