Skip to content

Commit 5c88657

Browse files
authored
Show dvc roots in tracked tree when there is more than one project in the workspace (#1951)
1 parent c83e763 commit 5c88657

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

extension/src/fileSystem/tree.test.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,24 @@ describe('TrackedTreeView', () => {
8282
)
8383
trackedTreeView.initialize(mockedDvcRoots)
8484

85-
const getRootPathItem = (dvcRoot: string) => ({
86-
dvcRoot,
87-
isDirectory: true,
88-
resourceUri: Uri.file(dvcRoot)
89-
})
90-
91-
mockedGetChildren.mockImplementation(dvcRoot => [
92-
getRootPathItem(dvcRoot)
93-
])
94-
9585
const rootElements = await trackedTreeView.getChildren()
9686

97-
expect(rootElements).toStrictEqual(mockedDvcRoots.map(getRootPathItem))
98-
expect(mockedGetRepository).toBeCalledTimes(2)
99-
expect(mockedGetRepository).toBeCalledWith(dvcDemoPath)
100-
expect(mockedGetRepository).toBeCalledWith(mockedOtherRoot)
101-
expect(mockedGetChildren).toBeCalledTimes(2)
87+
expect(rootElements).toStrictEqual([
88+
{
89+
dvcRoot: dvcDemoPath,
90+
isDirectory: true,
91+
isTracked: true,
92+
resourceUri: Uri.file(dvcDemoPath)
93+
},
94+
{
95+
dvcRoot: mockedOtherRoot,
96+
isDirectory: true,
97+
isTracked: true,
98+
resourceUri: Uri.file(mockedOtherRoot)
99+
}
100+
])
101+
expect(mockedGetRepository).toBeCalledTimes(0)
102+
expect(mockedGetChildren).toBeCalledTimes(0)
102103
})
103104

104105
it('should return directories first in the list of root items', async () => {

extension/src/fileSystem/tree.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class TrackedExplorerTree
112112
this.repositories.treeDataChanged.fire()
113113
}
114114

115-
private async getRootElements() {
115+
private getRootElements() {
116116
if (!this.viewed) {
117117
sendViewOpenedTelemetryEvent(
118118
EventName.VIEWS_TRACKED_EXPLORER_TREE_OPENED,
@@ -126,11 +126,12 @@ export class TrackedExplorerTree
126126
return this.getRepoChildren(onlyRoot)
127127
}
128128

129-
const rootChildren = await Promise.all(
130-
this.dvcRoots.map(dvcRoot => this.getRepoChildren(dvcRoot))
131-
)
132-
133-
return rootChildren.flat()
129+
return this.dvcRoots.map(dvcRoot => ({
130+
dvcRoot,
131+
isDirectory: true,
132+
isTracked: true,
133+
resourceUri: Uri.file(dvcRoot)
134+
}))
134135
}
135136

136137
private getDataPlaceholder({ fsPath }: { fsPath: string }): string {

0 commit comments

Comments
 (0)