File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,11 @@ export function isCSP(uri: vscode.Uri): boolean {
259
259
export function currentWorkspaceFolder ( document ?: vscode . TextDocument ) : string {
260
260
document = document ? document : vscode . window . activeTextEditor && vscode . window . activeTextEditor . document ;
261
261
if ( document ) {
262
- return workspaceFolderOfUri ( document . uri ) ;
262
+ const folder = workspaceFolderOfUri ( document . uri ) ;
263
+ // document might not be part of the workspace (e.g. the XXX.code-workspace JSON file)
264
+ if ( folder ) {
265
+ return folder ;
266
+ }
263
267
}
264
268
const firstFolder =
265
269
vscode . workspace . workspaceFolders && vscode . workspace . workspaceFolders . length
@@ -284,6 +288,7 @@ export function workspaceFolderOfUri(uri: vscode.Uri): string {
284
288
) ;
285
289
return foundFolder ? foundFolder . name : uri . authority ;
286
290
}
291
+ return "" ;
287
292
}
288
293
289
294
export function uriOfWorkspaceFolder ( workspaceFolder : string = currentWorkspaceFolder ( ) ) : vscode . Uri {
You can’t perform that action at this time.
0 commit comments