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