Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit da6bb20

Browse files
committed
add coments to the "Cargo.toml" search
1 parent 3c957c1 commit da6bb20

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/workspace_util.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,34 @@ export function nearestParentWorkspace(
1010
filePath: string,
1111
): WorkspaceFolder {
1212

13+
// check that the workspace folder already contains the "Cargo.toml"
1314
const workspaceRoot = path.parse(curWorkspace.uri.fsPath).dir;
1415
const rootManifest = path.join(workspaceRoot, 'Cargo.toml');
1516
if (fs.existsSync(rootManifest)) {
1617
return curWorkspace;
1718
}
1819

20+
// algorithm that will strip one folder at a time and check if that folder contains "Cargo.toml"
1921
let current = filePath;
20-
2122
while (true) {
2223
const old = current;
2324
current = path.dirname(current);
25+
26+
// break in case there is a bug that could result in a busy loop
2427
if (old === current) {
2528
break;
2629
}
30+
31+
// break in case the strip folder has not changed
2732
if (workspaceRoot === path.parse(current).dir) {
2833
break;
2934
}
3035

36+
// check if "Cargo.toml" is present in the parent folder
3137
const cargoPath = path.join(current, 'Cargo.toml');
3238
if (fs.existsSync(cargoPath)) {
39+
40+
// ghetto change the uri on Workspace folder to make vscode think it's located elsewhere
3341
return { ...curWorkspace, uri: Uri.parse(current) };
3442
}
3543
}

0 commit comments

Comments
 (0)