Skip to content

Commit

Permalink
Fix findWorkspaceRoot failing in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Nov 26, 2022
1 parent 23135ab commit 4346dad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ide/src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export let log = (...strs: any[]) => {
let s = strs.map((obj) => String(obj)).join("\t");
logs.push(s);
channel.appendLine(s);
console.log(...strs);
};
11 changes: 9 additions & 2 deletions ide/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export let cargo_command = (): [string, string[]] => {
let findWorkspaceRoot = async (): Promise<string | null> => {
let folders = vscode.workspace.workspaceFolders;
if (!folders || folders.length === 0) {
log("No folders exist");
return null;
}

Expand All @@ -129,12 +130,18 @@ let findWorkspaceRoot = async (): Promise<string | null> => {
}
};

let folderPath = folders[0].uri.fsPath;
if (hasCargoToml(folderPath)) return folderPath;

let activeEditor = vscode.window.activeTextEditor;
if (!activeEditor) return null;
if (!activeEditor) {
log("No active editor exists");
return null;
}

let folderPath = folders[0].uri.fsPath;
let activeFilePath = activeEditor.document.fileName;
log(`Looking for workspace root between ${folderPath} and ${activeFilePath}`);

let components = path.relative(folderPath, activeFilePath).split(path.sep);
let folderSubdirTil = (idx: number) =>
path.join(folderPath, ...components.slice(0, idx));
Expand Down

0 comments on commit 4346dad

Please sign in to comment.