Avoid null ref when workspace folder uri is undefined (#2179)

This commit is contained in:
Karl Burtram
2018-08-07 19:48:26 -04:00
committed by GitHub
parent eb48a9f993
commit d690b80493

View File

@@ -42,7 +42,10 @@ export function resolveFilePath(uri: string, filePath: string, rootPath: string)
export function getRootPath(contextService: IWorkspaceContextService): string {
let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
if (isWorkspace) {
return contextService.getWorkspace().folders[0].uri.fsPath;
let folder = contextService.getWorkspace().folders[0];
if (folder && folder.uri) {
return folder.uri.fsPath;
}
}
return undefined;