diff --git a/src/utils/fileUtils.ts b/src/utils/fileUtils.ts index c7132cdc..a05fbbeb 100644 --- a/src/utils/fileUtils.ts +++ b/src/utils/fileUtils.ts @@ -9,7 +9,7 @@ import { TextDocument, Uri, workspace, WorkspaceFolder } from "vscode"; */ export function getWorkspaceUri(document: TextDocument): Uri | undefined { const currentWorkspace: WorkspaceFolder = (document && document.uri) ? workspace.getWorkspaceFolder(document.uri) : undefined; - return ((currentWorkspace && currentWorkspace.uri) || (workspace.workspaceFolders && workspace.workspaceFolders[0].uri)); + return ((currentWorkspace && currentWorkspace.uri) || (workspace.workspaceFolders && workspace.workspaceFolders.length > 0 && workspace.workspaceFolders[0].uri)); } /** @@ -52,4 +52,4 @@ export function getRelativePath(startPath: string, destinationPath: string): str export function getDirectoryPath(filePath: string): string { return path.dirname(filePath); -} \ No newline at end of file +}