aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHannes De Valkeneer <[email protected]>2020-03-12 20:28:26 +0000
committerHannes De Valkeneer <[email protected]>2020-03-12 20:28:26 +0000
commite9d025b618aaa1a5a06e60c17392a18f12471217 (patch)
treef0af4d8a9eead1bb684cdee060411bbc6fee5bad /crates
parenta034257e5ed5a3758e1ea2f72b3b905d1b2b320a (diff)
fixup! feat: add debug code lens
avoid repetition of `--no-run`
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs17
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/main.rs7
2 files changed, 12 insertions, 12 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