@@ -82,28 +82,30 @@ export class TestTree extends vscode.Disposable {
82
82
return files
83
83
}
84
84
85
+ getSymlinkFolder ( uri : vscode . Uri ) {
86
+ const stats = lstatSync ( uri . fsPath )
87
+ if ( stats . isSymbolicLink ( ) ) {
88
+ const actualPath = readlinkSync ( uri . fsPath )
89
+ const dir = dirname ( uri . fsPath )
90
+ const id = resolve ( dir , actualPath )
91
+ return vscode . Uri . file ( id )
92
+ }
93
+ return uri
94
+ }
95
+
85
96
// in cases where there is only a single workspace, we don't show it as a folder
86
97
// this inline folder is required for "createFolderItem" to properly resolve the parent,
87
98
// otherwise it will go into an infinite loop
88
99
getOrCreateInlineFolderItem ( folderUri : vscode . Uri ) {
89
- let id = normalize ( folderUri . fsPath )
100
+ const symlinkUri = this . getSymlinkFolder ( folderUri )
101
+ const id = normalize ( symlinkUri . fsPath )
90
102
const cached = this . folderItems . get ( id )
91
103
if ( cached )
92
104
return cached
93
- const stats = lstatSync ( folderUri . fsPath )
94
- if ( stats . isSymbolicLink ( ) ) {
95
- const actualPath = readlinkSync ( folderUri . fsPath )
96
- const dir = dirname ( folderUri . fsPath )
97
- id = resolve ( dir , actualPath )
98
- folderUri = vscode . Uri . file ( id )
99
- }
100
- const cachedSymlink = this . folderItems . get ( id )
101
- if ( cachedSymlink )
102
- return cachedSymlink
103
105
const item : vscode . TestItem = {
104
- id : folderUri . toString ( ) ,
106
+ id : symlinkUri . toString ( ) ,
105
107
children : this . controller . items ,
106
- uri : folderUri ,
108
+ uri : symlinkUri ,
107
109
label : '<root>' ,
108
110
canResolveChildren : false ,
109
111
busy : false ,
@@ -114,17 +116,28 @@ export class TestTree extends vscode.Disposable {
114
116
}
115
117
TestFolder . register ( item )
116
118
this . folderItems . set ( id , item )
119
+
120
+ if ( symlinkUri !== folderUri ) {
121
+ const originalId = normalize ( folderUri . fsPath )
122
+ this . folderItems . set ( originalId , item )
123
+ }
117
124
return item
118
125
}
119
126
120
127
getOrCreateWorkspaceFolderItem ( folderUri : vscode . Uri ) {
121
- const folderId = normalize ( folderUri . fsPath )
128
+ const symlinkUri = this . getSymlinkFolder ( folderUri )
129
+ const folderId = normalize ( symlinkUri . fsPath )
122
130
const cached = this . folderItems . get ( folderId )
123
131
if ( cached )
124
132
return cached
125
133
126
- const folderItem = this . _createFolderItem ( folderUri )
134
+ const folderItem = this . _createFolderItem ( symlinkUri )
127
135
this . folderItems . set ( folderId , folderItem )
136
+ // if item is symlink, also store it in the symlink location
137
+ if ( symlinkUri !== folderUri ) {
138
+ const originalId = normalize ( folderUri . fsPath )
139
+ this . folderItems . set ( originalId , folderItem )
140
+ }
128
141
return folderItem
129
142
}
130
143
0 commit comments