aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs17
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs7
-rw-r--r--editors/code/src/commands/runnables.ts7
3 files changed, 13 insertions, 18 deletions
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index 07761f00a..f9715e675 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -795,24 +795,27 @@ pub fn handle_code_lens(
795 RunnableKind::Bin => "Run", 795 RunnableKind::Bin => "Run",
796 } 796 }
797 .to_string(); 797 .to_string();
798 let r = to_lsp_runnable(&world, file_id, runnable)?; 798 let mut r = to_lsp_runnable(&world, file_id, runnable)?;
799 let range = r.range;
800 let arguments = vec![to_value(r).unwrap()];
801 let lens = CodeLens { 799 let lens = CodeLens {
802 range: range.clone(), 800 range: r.range,
803 command: Some(Command { 801 command: Some(Command {
804 title, 802 title,
805 command: "rust-analyzer.runSingle".into(), 803 command: "rust-analyzer.runSingle".into(),
806 arguments: Some(arguments.clone()), 804 arguments: Some(vec![to_value(&r).unwrap()]),
807 }), 805 }),
808 data: None, 806 data: None,
809 }; 807 };
808 if r.args[0] == "run" {
809 r.args[0] = "build".into();
810 } else {
811 r.args.push("--no-run".into());
812 }
810 let debug_lens = CodeLens { 813 let debug_lens = CodeLens {
811 range, 814 range: r.range,
812 command: Some(Command { 815 command: Some(Command {
813 title: "Debug".into(), 816 title: "Debug".into(),
814 command: "rust-analyzer.debugSingle".into(), 817 command: "rust-analyzer.debugSingle".into(),
815 arguments: Some(arguments.clone()), 818 arguments: Some(vec![to_value(r).unwrap()]),
816 }), 819 }),
817 data: None, 820 data: None,
818 }; 821 };
diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs
index 55af6c5e0..145429571 100644
--- a/crates/rust-analyzer/tests/heavy_tests/main.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/main.rs
@@ -143,10 +143,7 @@ fn main() {}
143 143
144 server.wait_until_workspace_is_loaded(); 144 server.wait_until_workspace_is_loaded();
145 server.request::<Runnables>( 145 server.request::<Runnables>(
146 RunnablesParams { 146 RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
147 text_document: server.doc_id("foo/tests/spam.rs"),
148 position: None,
149 },
150 json!([ 147 json!([
151 { 148 {
152 "args": [ "test", "--package", "foo", "--test", "spam" ], 149 "args": [ "test", "--package", "foo", "--test", "spam" ],
@@ -184,7 +181,7 @@ fn main() {}
184 } 181 }
185 } 182 }
186 } 183 }
187 ]) 184 ]),
188 ); 185 );
189} 186}
190 187
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 51cfb37d5..357155163 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -67,12 +67,6 @@ export function debugSingle(ctx: Ctx): Cmd {
67 const editor = ctx.activeRustEditor; 67 const editor = ctx.activeRustEditor;
68 if (!editor) return; 68 if (!editor) return;
69 69
70 if (config.args[0] === 'run') {
71 config.args[0] = 'build';
72 } else {
73 config.args.push('--no-run');
74 }
75
76 const debugConfig = { 70 const debugConfig = {
77 type: "lldb", 71 type: "lldb",
78 request: "launch", 72 request: "launch",
@@ -83,6 +77,7 @@ export function debugSingle(ctx: Ctx): Cmd {
83 args: config.extraArgs, 77 args: config.extraArgs,
84 cwd: config.cwd 78 cwd: config.cwd
85 }; 79 };
80
86 return vscode.debug.startDebugging(undefined, debugConfig); 81 return vscode.debug.startDebugging(undefined, debugConfig);
87 }; 82 };
88} 83}