Skip to content

Commit bf40fbc

Browse files
committed
switch to using vscode URI API for directory slicing
1 parent 281b951 commit bf40fbc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

vscode/src/createProject.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,16 @@ export async function initProjectCreator(context: vscode.ExtensionContext) {
345345
// Note: At some point we may want to detect/avoid duplicate names, e.g. if the user already
346346
// references a project via 'foo', and they add a reference to a 'foo' on GitHub or in another dir.
347347

348-
const projectChoices: Array<{ name: string; ref: LocalProjectRef }> = [];
349-
350-
projectFiles.forEach((file) => {
351-
const dirName = file.path.slice(0, -"/qsharp.json".length);
352-
const relPath = getRelativeDirPath(qsharpJsonDir!.path, dirName);
353-
projectChoices.push({
354-
name: dirName.slice(dirName.lastIndexOf("/") + 1),
348+
const projectChoices = projectFiles.map((file) => {
349+
// normalize the path using the vscode Uri API
350+
const dirUri = vscode.Uri.joinPath(file, "..");
351+
const relPath = getRelativeDirPath(qsharpJsonDir!.path, dirUri.path);
352+
return {
353+
name: dirUri.path.split("/").pop()!,
355354
ref: {
356355
path: relPath,
357356
},
358-
});
357+
};
359358
});
360359

361360
projectChoices.forEach(

0 commit comments

Comments
 (0)