Skip to content

Commit

Permalink
XML support crashes when workspace folders are empty
Browse files Browse the repository at this point in the history
Fixes #940

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr authored and datho7561 committed Nov 7, 2023
1 parent 0e87aa6 commit 8263207
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -52,4 +52,4 @@ export function getRelativePath(startPath: string, destinationPath: string): str
export function getDirectoryPath(filePath: string): string {
return path.dirname(filePath);

}
}

0 comments on commit 8263207

Please sign in to comment.