diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-15 15:29:01 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-15 15:29:01 +0100 |
commit | d51c1f62178c383363a2d95e865131d9a7b969d0 (patch) | |
tree | 5235615134ab3798f21a167c71ce175795fc6798 /crates | |
parent | 982b92f966518a0e24632fafdc18d7b5ab6928b4 (diff) | |
parent | a4ecaa70969067c1149711dbf1f40a8a95cb5b72 (diff) |
Merge #4448
4448: Generate configuration for launch.json r=vsrs a=vsrs
This PR adds two new commands: `"rust-analyzer.debug"` and `"rust-analyzer.newDebugConfig"`. The former is a supplement to the existing `"rust-analyzer.run"` command and works the same way: asks for a runnable and starts new debug session. The latter allows adding a new configuration to **launch.json** (or to update an existing one).
If the new option `"rust-analyzer.debug.useLaunchJson"` is set to true then `"rust-analyzer.debug"` and Debug Lens will first look for existing debug configuration in **launch.json**. That is, it has become possible to specify startup arguments, env variables, etc.
`"rust-analyzer.debug.useLaunchJson"` is false by default, but it might be worth making true the default value. Personally I prefer true, but I'm not sure if it is good for all value.
----
I think that this PR also solves https://github.com/rust-analyzer/rust-analyzer/issues/3441.
Both methods to update launch.json mentioned in the issue do not work:
1. Menu. It is only possible to add a launch.json configuration template via a debug adapter. And anyway it's only a template and it is impossible to specify arguments from an extension.
2. DebugConfigurationProvider. The exact opposite situation: it is possible to specify all debug session settings, but it is impossible to export these settings to launch.json.
Separate `"rust-analyzer.newDebugConfig"` command looks better for me.
----
Fixes #4450
Fixes #3441
Co-authored-by: vsrs <[email protected]>
Co-authored-by: vsrs <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 8d7baa14f..6b14830b6 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs | |||
@@ -1011,6 +1011,7 @@ fn to_lsp_runnable( | |||
1011 | runnable: Runnable, | 1011 | runnable: Runnable, |
1012 | ) -> Result<lsp_ext::Runnable> { | 1012 | ) -> Result<lsp_ext::Runnable> { |
1013 | let spec = CargoTargetSpec::for_file(world, file_id)?; | 1013 | let spec = CargoTargetSpec::for_file(world, file_id)?; |
1014 | let target = spec.as_ref().map(|s| s.target.clone()); | ||
1014 | let (args, extra_args) = CargoTargetSpec::runnable_args(spec, &runnable.kind)?; | 1015 | let (args, extra_args) = CargoTargetSpec::runnable_args(spec, &runnable.kind)?; |
1015 | let line_index = world.analysis().file_line_index(file_id)?; | 1016 | let line_index = world.analysis().file_line_index(file_id)?; |
1016 | let label = match &runnable.kind { | 1017 | let label = match &runnable.kind { |
@@ -1018,7 +1019,9 @@ fn to_lsp_runnable( | |||
1018 | RunnableKind::TestMod { path } => format!("test-mod {}", path), | 1019 | RunnableKind::TestMod { path } => format!("test-mod {}", path), |
1019 | RunnableKind::Bench { test_id } => format!("bench {}", test_id), | 1020 | RunnableKind::Bench { test_id } => format!("bench {}", test_id), |
1020 | RunnableKind::DocTest { test_id, .. } => format!("doctest {}", test_id), | 1021 | RunnableKind::DocTest { test_id, .. } => format!("doctest {}", test_id), |
1021 | RunnableKind::Bin => "run binary".to_string(), | 1022 | RunnableKind::Bin => { |
1023 | target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t)) | ||
1024 | } | ||
1022 | }; | 1025 | }; |
1023 | Ok(lsp_ext::Runnable { | 1026 | Ok(lsp_ext::Runnable { |
1024 | range: to_proto::range(&line_index, runnable.range), | 1027 | range: to_proto::range(&line_index, runnable.range), |