1use dap_types::SteppingGranularity;
2use gpui::App;
3use settings::{Settings, SettingsContent};
4
5pub struct DebuggerSettings {
6 /// Determines the stepping granularity.
7 ///
8 /// Default: line
9 pub stepping_granularity: SteppingGranularity,
10 /// Whether the breakpoints should be reused across Zed sessions.
11 ///
12 /// Default: true
13 pub save_breakpoints: bool,
14 /// Whether to show the debug button in the status bar.
15 ///
16 /// Default: true
17 pub button: bool,
18 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
19 ///
20 /// Default: 2000ms
21 pub timeout: u64,
22 /// Whether to log messages between active debug adapters and Zed
23 ///
24 /// Default: true
25 pub log_dap_communications: bool,
26 /// Whether to format dap messages in when adding them to debug adapter logger
27 ///
28 /// Default: true
29 pub format_dap_log_messages: bool,
30 /// The dock position of the debug panel
31 ///
32 /// Default: Bottom
33 pub dock: settings::DockPosition,
34}
35
36impl Settings for DebuggerSettings {
37 fn from_settings(content: &SettingsContent, _cx: &mut App) -> Self {
38 let content = content.debugger.clone().unwrap();
39 Self {
40 stepping_granularity: dap_granularity_from_settings(
41 content.stepping_granularity.unwrap(),
42 ),
43 save_breakpoints: content.save_breakpoints.unwrap(),
44 button: content.button.unwrap(),
45 timeout: content.timeout.unwrap(),
46 log_dap_communications: content.log_dap_communications.unwrap(),
47 format_dap_log_messages: content.format_dap_log_messages.unwrap(),
48 dock: content.dock.unwrap(),
49 }
50 }
51}
52
53fn dap_granularity_from_settings(
54 granularity: settings::SteppingGranularity,
55) -> dap_types::SteppingGranularity {
56 match granularity {
57 settings::SteppingGranularity::Instruction => dap_types::SteppingGranularity::Instruction,
58 settings::SteppingGranularity::Line => dap_types::SteppingGranularity::Line,
59 settings::SteppingGranularity::Statement => dap_types::SteppingGranularity::Statement,
60 }
61}