Skip to content

Commit

Permalink
fix #138 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
fr43nk authored Mar 20, 2023
1 parent e1fda8f commit 366c244
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/clearcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ export class ClearCase {
*/
async getVersionInformation(iUri: Uri, normalize = true): Promise<string> {
return new Promise<string>((resolve, reject) => {
if (iUri === undefined || workspace.workspaceFolders === undefined) {
if (iUri === undefined ||
workspace.workspaceFolders === undefined ||
this.checkIfInWorkspace(iUri.fsPath) === false) {
reject("");
} else {
let fileVers = "";
Expand Down Expand Up @@ -1041,4 +1043,26 @@ export class ClearCase {
}
return path;
}

/**
* check if the file is within the current workspace
* avoid error messages related to files edited outside the current workspace
*/
private checkIfInWorkspace(file: string): boolean {
let ret = false;
if (workspace.workspaceFolders && file !== "") {
for (const wsPath of workspace.workspaceFolders) {
try {
fs.accessSync(wsPath.uri.fsPath, fs.constants.F_OK);
ret = file.includes(wsPath.uri.fsPath);
if (ret === true) {
break;
}
} catch (e) {
ret = false;
}
}
}
return ret;
}
}

0 comments on commit 366c244

Please sign in to comment.