about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-04 06:21:34 +0000
committerbors <bors@rust-lang.org>2023-04-04 06:21:34 +0000
commite8715401716311b93d53eac37198126a9d6690be (patch)
tree3b7ffec5a95845cf35423f9cc156565dcb738f2f
parentf070093462bee3d0560b9c532870e51352ce0ceb (diff)
parent7989a9439181873c30a21df8e28d58fbe69e26a5 (diff)
downloadrust-e8715401716311b93d53eac37198126a9d6690be.tar.gz
rust-e8715401716311b93d53eac37198126a9d6690be.zip
Auto merge of #14482 - Veykril:vscode-linking-popup, r=Veykril
fix: Fix relative path creation using the wrong path accessor

This should hopefully fix the other errors with paths people seem to be getting
-rw-r--r--editors/code/src/client.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 1db02e21058..e76710cb247 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -142,23 +142,27 @@ export async function createClient(
                                     );
                                     void vscode.workspace.fs.stat(path).then(async () => {
                                         const choice = await vscode.window.showInformationMessage(
-                                            `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${path}, do you want to add it to the linked Projects?`,
+                                            `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${path.path}, do you want to add it to the linked Projects?`,
                                             "Yes",
                                             "No",
                                             "Don't show this again"
                                         );
                                         switch (choice) {
+                                            case undefined:
+                                                break;
                                             case "No":
                                                 break;
                                             case "Yes":
+                                                const pathToInsert =
+                                                    "." +
+                                                    parent.substring(folder.length) +
+                                                    pathSeparator +
+                                                    "Cargo.toml";
                                                 await config.update(
                                                     "linkedProjects",
                                                     config
                                                         .get<any[]>("linkedProjects")
-                                                        ?.concat(
-                                                            "." +
-                                                                path.fsPath.substring(folder.length)
-                                                        ),
+                                                        ?.concat(pathToInsert),
                                                     false
                                                 );
                                                 break;