Skip to content

Commit 39c92b3

Browse files
committed
fixup! feat: add debug code lens
autodetect vscode-lldb
1 parent e9d025b commit 39c92b3

File tree

7 files changed

+26
-19
lines changed

7 files changed

+26
-19
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct ServerConfig {
5151

5252
/// Cargo feature configurations.
5353
pub cargo_features: CargoFeatures,
54+
55+
/// Enabled if the vscode_lldb extension is available.
56+
pub vscode_lldb: bool,
5457
}
5558

5659
impl Default for ServerConfig {
@@ -70,6 +73,7 @@ impl Default for ServerConfig {
7073
additional_out_dirs: FxHashMap::default(),
7174
cargo_features: Default::default(),
7275
rustfmt_args: Vec::new(),
76+
vscode_lldb: false,
7377
}
7478
}
7579
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub fn main_loop(
185185
all_targets: config.cargo_watch_all_targets,
186186
},
187187
rustfmt_args: config.rustfmt_args,
188+
vscode_lldb: config.vscode_lldb,
188189
}
189190
};
190191

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -805,23 +805,25 @@ pub fn handle_code_lens(
805805
}),
806806
data: None,
807807
};
808-
if r.args[0] == "run" {
809-
r.args[0] = "build".into();
810-
} else {
811-
r.args.push("--no-run".into());
812-
}
813-
let debug_lens = CodeLens {
814-
range: r.range,
815-
command: Some(Command {
816-
title: "Debug".into(),
817-
command: "rust-analyzer.debugSingle".into(),
818-
arguments: Some(vec![to_value(r).unwrap()]),
819-
}),
820-
data: None,
821-
};
822-
823808
lenses.push(lens);
824-
lenses.push(debug_lens);
809+
810+
if world.options.vscode_lldb {
811+
if r.args[0] == "run" {
812+
r.args[0] = "build".into();
813+
} else {
814+
r.args.push("--no-run".into());
815+
}
816+
let debug_lens = CodeLens {
817+
range: r.range,
818+
command: Some(Command {
819+
title: "Debug".into(),
820+
command: "rust-analyzer.debugSingle".into(),
821+
arguments: Some(vec![to_value(r).unwrap()]),
822+
}),
823+
data: None,
824+
};
825+
lenses.push(debug_lens);
826+
}
825827
}
826828

827829
// Handle impls

crates/rust-analyzer/src/world.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct Options {
3737
pub max_inlay_hint_length: Option<usize>,
3838
pub rustfmt_args: Vec<String>,
3939
pub cargo_watch: CheckOptions,
40+
pub vscode_lldb: bool,
4041
}
4142

4243
/// `WorldState` is the primary mutable state of the language server

editors/code/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
"typescript-formatter": "^7.2.2",
5252
"vsce": "^1.74.0"
5353
},
54-
"extensionDependencies": [
55-
"vadimcn.vscode-lldb"
56-
],
5754
"activationEvents": [
5855
"onLanguage:rust",
5956
"onCommand:rust-analyzer.analyzerStatus",

editors/code/src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export async function createClient(config: Config, serverPath: string): Promise<
4141
withSysroot: config.withSysroot,
4242
cargoFeatures: config.cargoFeatures,
4343
rustfmtArgs: config.rustfmtArgs,
44+
vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
4445
},
4546
traceOutputChannel,
4647
middleware: {

editors/code/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export class Config {
156156
get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; }
157157
get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record<string, string>; }
158158
get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; }
159+
get vscodeLldb() { return this.cfg.get("vscodeLldb") as boolean; }
159160

160161
get cargoWatchOptions(): CargoWatchOptions {
161162
return {

0 commit comments

Comments
 (0)