debugger_settings.rs

 1use dap_types::SteppingGranularity;
 2use gpui::{App, Global};
 3use schemars::JsonSchema;
 4use serde::{Deserialize, Serialize};
 5use settings::{Settings, SettingsSources, SettingsUi};
 6
 7#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, SettingsUi)]
 8#[serde(rename_all = "snake_case")]
 9pub enum DebugPanelDockPosition {
10    Left,
11    Bottom,
12    Right,
13}
14
15#[derive(Serialize, Deserialize, JsonSchema, Clone, Copy, SettingsUi)]
16#[serde(default)]
17// todo(settings_ui) @ben: I'm pretty sure not having the fields be optional here is a bug,
18// it means the defaults will override previously set values if a single key is missing
19#[settings_ui(group = "Debugger", path = "debugger")]
20pub struct DebuggerSettings {
21    /// Determines the stepping granularity.
22    ///
23    /// Default: line
24    #[settings_ui(skip)]
25    pub stepping_granularity: SteppingGranularity,
26    /// Whether the breakpoints should be reused across Zed sessions.
27    ///
28    /// Default: true
29    pub save_breakpoints: bool,
30    /// Whether to show the debug button in the status bar.
31    ///
32    /// Default: true
33    pub button: bool,
34    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
35    ///
36    /// Default: 2000ms
37    pub timeout: u64,
38    /// Whether to log messages between active debug adapters and Zed
39    ///
40    /// Default: true
41    pub log_dap_communications: bool,
42    /// Whether to format dap messages in when adding them to debug adapter logger
43    ///
44    /// Default: true
45    pub format_dap_log_messages: bool,
46    /// The dock position of the debug panel
47    ///
48    /// Default: Bottom
49    pub dock: DebugPanelDockPosition,
50}
51
52impl Default for DebuggerSettings {
53    fn default() -> Self {
54        Self {
55            button: true,
56            save_breakpoints: true,
57            stepping_granularity: SteppingGranularity::Line,
58            timeout: 2000,
59            log_dap_communications: true,
60            format_dap_log_messages: true,
61            dock: DebugPanelDockPosition::Bottom,
62        }
63    }
64}
65
66impl Settings for DebuggerSettings {
67    const KEY: Option<&'static str> = Some("debugger");
68
69    type FileContent = Self;
70
71    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> anyhow::Result<Self> {
72        sources.json_merge()
73    }
74
75    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
76}
77
78impl Global for DebuggerSettings {}