about summary refs log tree commit diff
diff options
context:
space:
mode:
authorroife <roifewu@gmail.com>2024-05-22 14:29:34 +0800
committerroife <roifewu@gmail.com>2024-05-24 03:51:05 +0800
commit1a37cfb7038a30bb7d07d07cfa4ccde022788773 (patch)
treeb5c97d0bba972d0c47597caef3f7cac89590c2fc
parent7b54c8231eabad1fdb783ab63490336c31adcd4e (diff)
downloadrust-1a37cfb7038a30bb7d07d07cfa4ccde022788773.tar.gz
rust-1a37cfb7038a30bb7d07d07cfa4ccde022788773.zip
Use cwd from runnable.args for debugger
-rw-r--r--src/tools/rust-analyzer/editors/code/src/debug.ts6
-rw-r--r--src/tools/rust-analyzer/editors/code/src/lsp_ext.ts1
2 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/debug.ts b/src/tools/rust-analyzer/editors/code/src/debug.ts
index 0f90ed34ef1..855e8b082ae 100644
--- a/src/tools/rust-analyzer/editors/code/src/debug.ts
+++ b/src/tools/rust-analyzer/editors/code/src/debug.ts
@@ -192,7 +192,7 @@ function getCCppDebugConfig(
         name: runnable.label,
         program: executable,
         args: runnable.args.executableArgs,
-        cwd: runnable.args.workspaceRoot,
+        cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",
         sourceFileMap,
         env,
         // See https://github.com/rust-lang/rust-analyzer/issues/16901#issuecomment-2024486941
@@ -214,7 +214,7 @@ function getCodeLldbDebugConfig(
         name: runnable.label,
         program: executable,
         args: runnable.args.executableArgs,
-        cwd: runnable.args.workspaceRoot,
+        cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",
         sourceMap: sourceFileMap,
         sourceLanguages: ["rust"],
         env,
@@ -234,7 +234,7 @@ function getNativeDebugConfig(
         target: executable,
         // See https://github.com/WebFreak001/code-debug/issues/359
         arguments: quote(runnable.args.executableArgs),
-        cwd: runnable.args.workspaceRoot,
+        cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",
         env,
         valuesFormatting: "prettyPrinters",
     };
diff --git a/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts b/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts
index 9a7a4aae959..8e48aeef158 100644
--- a/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts
+++ b/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts
@@ -226,6 +226,7 @@ export type Runnable = {
     kind: "cargo";
     args: {
         workspaceRoot?: string;
+        cwd?: string;
         cargoArgs: string[];
         cargoExtraArgs: string[];
         executableArgs: string[];