editor_settings.rs

  1use gpui::App;
  2use language::CursorShape;
  3use project::project_settings::DiagnosticSeverity;
  4use schemars::JsonSchema;
  5use serde::{Deserialize, Serialize};
  6use settings::{Settings, SettingsSources, VsCodeSettings};
  7use util::serde::default_true;
  8
  9/// Imports from the VSCode settings at
 10/// https://code.visualstudio.com/docs/reference/default-settings
 11#[derive(Deserialize, Clone)]
 12pub struct EditorSettings {
 13    pub cursor_blink: bool,
 14    pub cursor_shape: Option<CursorShape>,
 15    pub current_line_highlight: CurrentLineHighlight,
 16    pub selection_highlight: bool,
 17    pub lsp_highlight_debounce: u64,
 18    pub hover_popover_enabled: bool,
 19    pub hover_popover_delay: u64,
 20    pub toolbar: Toolbar,
 21    pub scrollbar: Scrollbar,
 22    pub minimap: Minimap,
 23    pub gutter: Gutter,
 24    pub scroll_beyond_last_line: ScrollBeyondLastLine,
 25    pub vertical_scroll_margin: f32,
 26    pub autoscroll_on_clicks: bool,
 27    pub horizontal_scroll_margin: f32,
 28    pub scroll_sensitivity: f32,
 29    pub relative_line_numbers: bool,
 30    pub seed_search_query_from_cursor: SeedQuerySetting,
 31    pub use_smartcase_search: bool,
 32    pub multi_cursor_modifier: MultiCursorModifier,
 33    pub redact_private_values: bool,
 34    pub expand_excerpt_lines: u32,
 35    pub middle_click_paste: bool,
 36    #[serde(default)]
 37    pub double_click_in_multibuffer: DoubleClickInMultibuffer,
 38    pub search_wrap: bool,
 39    #[serde(default)]
 40    pub search: SearchSettings,
 41    pub auto_signature_help: bool,
 42    pub show_signature_help_after_edits: bool,
 43    #[serde(default)]
 44    pub go_to_definition_fallback: GoToDefinitionFallback,
 45    pub jupyter: Jupyter,
 46    pub hide_mouse: Option<HideMouseMode>,
 47    pub snippet_sort_order: SnippetSortOrder,
 48    #[serde(default)]
 49    pub diagnostics_max_severity: Option<DiagnosticSeverity>,
 50}
 51
 52#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 53#[serde(rename_all = "snake_case")]
 54pub enum CurrentLineHighlight {
 55    // Don't highlight the current line.
 56    None,
 57    // Highlight the gutter area.
 58    Gutter,
 59    // Highlight the editor area.
 60    Line,
 61    // Highlight the full line.
 62    All,
 63}
 64
 65/// When to populate a new search's query based on the text under the cursor.
 66#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 67#[serde(rename_all = "snake_case")]
 68pub enum SeedQuerySetting {
 69    /// Always populate the search query with the word under the cursor.
 70    Always,
 71    /// Only populate the search query when there is text selected.
 72    Selection,
 73    /// Never populate the search query
 74    Never,
 75}
 76
 77/// What to do when multibuffer is double clicked in some of its excerpts (parts of singleton buffers).
 78#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 79#[serde(rename_all = "snake_case")]
 80pub enum DoubleClickInMultibuffer {
 81    /// Behave as a regular buffer and select the whole word.
 82    #[default]
 83    Select,
 84    /// Open the excerpt clicked as a new buffer in the new tab, if no `alt` modifier was pressed during double click.
 85    /// Otherwise, behave as a regular buffer and select the whole word.
 86    Open,
 87}
 88
 89#[derive(Debug, Clone, Deserialize)]
 90pub struct Jupyter {
 91    /// Whether the Jupyter feature is enabled.
 92    ///
 93    /// Default: true
 94    pub enabled: bool,
 95}
 96
 97#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 98#[serde(rename_all = "snake_case")]
 99pub struct JupyterContent {
100    /// Whether the Jupyter feature is enabled.
101    ///
102    /// Default: true
103    pub enabled: Option<bool>,
104}
105
106#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
107pub struct Toolbar {
108    pub breadcrumbs: bool,
109    pub quick_actions: bool,
110    pub selections_menu: bool,
111    pub agent_review: bool,
112    pub code_actions: bool,
113}
114
115#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
116pub struct Scrollbar {
117    pub show: ShowScrollbar,
118    pub git_diff: bool,
119    pub selected_text: bool,
120    pub selected_symbol: bool,
121    pub search_results: bool,
122    pub diagnostics: ScrollbarDiagnostics,
123    pub cursors: bool,
124    pub axes: ScrollbarAxes,
125}
126
127#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
128pub struct Minimap {
129    pub show: ShowMinimap,
130    pub thumb: MinimapThumb,
131    pub thumb_border: MinimapThumbBorder,
132    pub current_line_highlight: Option<CurrentLineHighlight>,
133}
134
135impl Minimap {
136    pub fn minimap_enabled(&self) -> bool {
137        self.show != ShowMinimap::Never
138    }
139
140    pub fn with_show_override(self) -> Self {
141        Self {
142            show: ShowMinimap::Always,
143            ..self
144        }
145    }
146}
147
148#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
149pub struct Gutter {
150    pub line_numbers: bool,
151    pub runnables: bool,
152    pub breakpoints: bool,
153    pub folds: bool,
154}
155
156/// When to show the scrollbar in the editor.
157///
158/// Default: auto
159#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
160#[serde(rename_all = "snake_case")]
161pub enum ShowScrollbar {
162    /// Show the scrollbar if there's important information or
163    /// follow the system's configured behavior.
164    Auto,
165    /// Match the system's configured behavior.
166    System,
167    /// Always show the scrollbar.
168    Always,
169    /// Never show the scrollbar.
170    Never,
171}
172
173/// When to show the minimap in the editor.
174///
175/// Default: never
176#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
177#[serde(rename_all = "snake_case")]
178pub enum ShowMinimap {
179    /// Follow the visibility of the scrollbar.
180    Auto,
181    /// Always show the minimap.
182    Always,
183    /// Never show the minimap.
184    #[default]
185    Never,
186}
187
188/// When to show the minimap thumb.
189///
190/// Default: always
191#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
192#[serde(rename_all = "snake_case")]
193pub enum MinimapThumb {
194    /// Show the minimap thumb only when the mouse is hovering over the minimap.
195    Hover,
196    /// Always show the minimap thumb.
197    #[default]
198    Always,
199}
200
201/// Defines the border style for the minimap's scrollbar thumb.
202///
203/// Default: left_open
204#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
205#[serde(rename_all = "snake_case")]
206pub enum MinimapThumbBorder {
207    /// Displays a border on all sides of the thumb.
208    Full,
209    /// Displays a border on all sides except the left side of the thumb.
210    #[default]
211    LeftOpen,
212    /// Displays a border on all sides except the right side of the thumb.
213    RightOpen,
214    /// Displays a border only on the left side of the thumb.
215    LeftOnly,
216    /// Displays the thumb without any border.
217    None,
218}
219
220/// Forcefully enable or disable the scrollbar for each axis
221#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
222#[serde(rename_all = "lowercase")]
223pub struct ScrollbarAxes {
224    /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
225    ///
226    /// Default: true
227    pub horizontal: bool,
228
229    /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
230    ///
231    /// Default: true
232    pub vertical: bool,
233}
234
235/// Which diagnostic indicators to show in the scrollbar.
236///
237/// Default: all
238#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
239#[serde(rename_all = "lowercase")]
240pub enum ScrollbarDiagnostics {
241    /// Show all diagnostic levels: hint, information, warnings, error.
242    All,
243    /// Show only the following diagnostic levels: information, warning, error.
244    Information,
245    /// Show only the following diagnostic levels: warning, error.
246    Warning,
247    /// Show only the following diagnostic level: error.
248    Error,
249    /// Do not show diagnostics.
250    None,
251}
252
253/// The key to use for adding multiple cursors
254///
255/// Default: alt
256#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
257#[serde(rename_all = "snake_case")]
258pub enum MultiCursorModifier {
259    Alt,
260    #[serde(alias = "cmd", alias = "ctrl")]
261    CmdOrCtrl,
262}
263
264/// Whether the editor will scroll beyond the last line.
265///
266/// Default: one_page
267#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
268#[serde(rename_all = "snake_case")]
269pub enum ScrollBeyondLastLine {
270    /// The editor will not scroll beyond the last line.
271    Off,
272
273    /// The editor will scroll beyond the last line by one page.
274    OnePage,
275
276    /// The editor will scroll beyond the last line by the same number of lines as vertical_scroll_margin.
277    VerticalScrollMargin,
278}
279
280/// Default options for buffer and project search items.
281#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
282pub struct SearchSettings {
283    /// Whether to show the project search button in the status bar.
284    #[serde(default = "default_true")]
285    pub button: bool,
286    #[serde(default)]
287    pub whole_word: bool,
288    #[serde(default)]
289    pub case_sensitive: bool,
290    #[serde(default)]
291    pub include_ignored: bool,
292    #[serde(default)]
293    pub regex: bool,
294}
295
296/// What to do when go to definition yields no results.
297#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
298#[serde(rename_all = "snake_case")]
299pub enum GoToDefinitionFallback {
300    /// Disables the fallback.
301    None,
302    /// Looks up references of the same symbol instead.
303    #[default]
304    FindAllReferences,
305}
306
307/// Determines when the mouse cursor should be hidden in an editor or input box.
308///
309/// Default: on_typing_and_movement
310#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
311#[serde(rename_all = "snake_case")]
312pub enum HideMouseMode {
313    /// Never hide the mouse cursor
314    Never,
315    /// Hide only when typing
316    OnTyping,
317    /// Hide on both typing and cursor movement
318    #[default]
319    OnTypingAndMovement,
320}
321
322/// Determines how snippets are sorted relative to other completion items.
323///
324/// Default: inline
325#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
326#[serde(rename_all = "snake_case")]
327pub enum SnippetSortOrder {
328    /// Place snippets at the top of the completion list
329    Top,
330    /// Sort snippets normally using the default comparison logic
331    #[default]
332    Inline,
333    /// Place snippets at the bottom of the completion list
334    Bottom,
335}
336
337#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
338#[schemars(deny_unknown_fields)]
339pub struct EditorSettingsContent {
340    /// Whether the cursor blinks in the editor.
341    ///
342    /// Default: true
343    pub cursor_blink: Option<bool>,
344    /// Cursor shape for the default editor.
345    /// Can be "bar", "block", "underline", or "hollow".
346    ///
347    /// Default: None
348    pub cursor_shape: Option<CursorShape>,
349    /// Determines when the mouse cursor should be hidden in an editor or input box.
350    ///
351    /// Default: on_typing_and_movement
352    pub hide_mouse: Option<HideMouseMode>,
353    /// Determines how snippets are sorted relative to other completion items.
354    ///
355    /// Default: inline
356    pub snippet_sort_order: Option<SnippetSortOrder>,
357    /// How to highlight the current line in the editor.
358    ///
359    /// Default: all
360    pub current_line_highlight: Option<CurrentLineHighlight>,
361    /// Whether to highlight all occurrences of the selected text in an editor.
362    ///
363    /// Default: true
364    pub selection_highlight: Option<bool>,
365    /// The debounce delay before querying highlights from the language
366    /// server based on the current cursor location.
367    ///
368    /// Default: 75
369    pub lsp_highlight_debounce: Option<u64>,
370    /// Whether to show the informational hover box when moving the mouse
371    /// over symbols in the editor.
372    ///
373    /// Default: true
374    pub hover_popover_enabled: Option<bool>,
375    /// Time to wait in milliseconds before showing the informational hover box.
376    ///
377    /// Default: 300
378    pub hover_popover_delay: Option<u64>,
379    /// Toolbar related settings
380    pub toolbar: Option<ToolbarContent>,
381    /// Scrollbar related settings
382    pub scrollbar: Option<ScrollbarContent>,
383    /// Minimap related settings
384    pub minimap: Option<MinimapContent>,
385    /// Gutter related settings
386    pub gutter: Option<GutterContent>,
387    /// Whether the editor will scroll beyond the last line.
388    ///
389    /// Default: one_page
390    pub scroll_beyond_last_line: Option<ScrollBeyondLastLine>,
391    /// The number of lines to keep above/below the cursor when auto-scrolling.
392    ///
393    /// Default: 3.
394    pub vertical_scroll_margin: Option<f32>,
395    /// Whether to scroll when clicking near the edge of the visible text area.
396    ///
397    /// Default: false
398    pub autoscroll_on_clicks: Option<bool>,
399    /// The number of characters to keep on either side when scrolling with the mouse.
400    ///
401    /// Default: 5.
402    pub horizontal_scroll_margin: Option<f32>,
403    /// Scroll sensitivity multiplier. This multiplier is applied
404    /// to both the horizontal and vertical delta values while scrolling.
405    ///
406    /// Default: 1.0
407    pub scroll_sensitivity: Option<f32>,
408    /// Whether the line numbers on editors gutter are relative or not.
409    ///
410    /// Default: false
411    pub relative_line_numbers: Option<bool>,
412    /// When to populate a new search's query based on the text under the cursor.
413    ///
414    /// Default: always
415    pub seed_search_query_from_cursor: Option<SeedQuerySetting>,
416    pub use_smartcase_search: Option<bool>,
417    /// The key to use for adding multiple cursors
418    ///
419    /// Default: alt
420    pub multi_cursor_modifier: Option<MultiCursorModifier>,
421    /// Hide the values of variables in `private` files, as defined by the
422    /// private_files setting. This only changes the visual representation,
423    /// the values are still present in the file and can be selected / copied / pasted
424    ///
425    /// Default: false
426    pub redact_private_values: Option<bool>,
427
428    /// How many lines to expand the multibuffer excerpts by default
429    ///
430    /// Default: 3
431    pub expand_excerpt_lines: Option<u32>,
432
433    /// Whether to enable middle-click paste on Linux
434    ///
435    /// Default: true
436    pub middle_click_paste: Option<bool>,
437
438    /// What to do when multibuffer is double clicked in some of its excerpts
439    /// (parts of singleton buffers).
440    ///
441    /// Default: select
442    pub double_click_in_multibuffer: Option<DoubleClickInMultibuffer>,
443    /// Whether the editor search results will loop
444    ///
445    /// Default: true
446    pub search_wrap: Option<bool>,
447
448    /// Defaults to use when opening a new buffer and project search items.
449    ///
450    /// Default: nothing is enabled
451    pub search: Option<SearchSettings>,
452
453    /// Whether to automatically show a signature help pop-up or not.
454    ///
455    /// Default: false
456    pub auto_signature_help: Option<bool>,
457
458    /// Whether to show the signature help pop-up after completions or bracket pairs inserted.
459    ///
460    /// Default: false
461    pub show_signature_help_after_edits: Option<bool>,
462
463    /// Whether to follow-up empty go to definition responses from the language server or not.
464    /// `FindAllReferences` allows to look up references of the same symbol instead.
465    /// `None` disables the fallback.
466    ///
467    /// Default: FindAllReferences
468    pub go_to_definition_fallback: Option<GoToDefinitionFallback>,
469
470    /// Jupyter REPL settings.
471    pub jupyter: Option<JupyterContent>,
472
473    /// Which level to use to filter out diagnostics displayed in the editor.
474    ///
475    /// Affects the editor rendering only, and does not interrupt
476    /// the functionality of diagnostics fetching and project diagnostics editor.
477    /// Which files containing diagnostic errors/warnings to mark in the tabs.
478    /// Diagnostics are only shown when file icons are also active.
479    ///
480    /// Shows all diagnostics if not specified.
481    ///
482    /// Default: warning
483    #[serde(default)]
484    pub diagnostics_max_severity: Option<DiagnosticSeverity>,
485}
486
487// Toolbar related settings
488#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
489pub struct ToolbarContent {
490    /// Whether to display breadcrumbs in the editor toolbar.
491    ///
492    /// Default: true
493    pub breadcrumbs: Option<bool>,
494    /// Whether to display quick action buttons in the editor toolbar.
495    ///
496    /// Default: true
497    pub quick_actions: Option<bool>,
498    /// Whether to show the selections menu in the editor toolbar.
499    ///
500    /// Default: true
501    pub selections_menu: Option<bool>,
502    /// Whether to display Agent review buttons in the editor toolbar.
503    /// Only applicable while reviewing a file edited by the Agent.
504    ///
505    /// Default: true
506    pub agent_review: Option<bool>,
507    /// Whether to display code action buttons in the editor toolbar.
508    ///
509    /// Default: true
510    pub code_actions: Option<bool>,
511}
512
513/// Scrollbar related settings
514#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)]
515pub struct ScrollbarContent {
516    /// When to show the scrollbar in the editor.
517    ///
518    /// Default: auto
519    pub show: Option<ShowScrollbar>,
520    /// Whether to show git diff indicators in the scrollbar.
521    ///
522    /// Default: true
523    pub git_diff: Option<bool>,
524    /// Whether to show buffer search result indicators in the scrollbar.
525    ///
526    /// Default: true
527    pub search_results: Option<bool>,
528    /// Whether to show selected text occurrences in the scrollbar.
529    ///
530    /// Default: true
531    pub selected_text: Option<bool>,
532    /// Whether to show selected symbol occurrences in the scrollbar.
533    ///
534    /// Default: true
535    pub selected_symbol: Option<bool>,
536    /// Which diagnostic indicators to show in the scrollbar:
537    ///
538    /// Default: all
539    pub diagnostics: Option<ScrollbarDiagnostics>,
540    /// Whether to show cursor positions in the scrollbar.
541    ///
542    /// Default: true
543    pub cursors: Option<bool>,
544    /// Forcefully enable or disable the scrollbar for each axis
545    pub axes: Option<ScrollbarAxesContent>,
546}
547
548/// Minimap related settings
549#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
550pub struct MinimapContent {
551    /// When to show the minimap in the editor.
552    ///
553    /// Default: never
554    pub show: Option<ShowMinimap>,
555
556    /// When to show the minimap thumb.
557    ///
558    /// Default: always
559    pub thumb: Option<MinimapThumb>,
560
561    /// Defines the border style for the minimap's scrollbar thumb.
562    ///
563    /// Default: left_open
564    pub thumb_border: Option<MinimapThumbBorder>,
565
566    /// How to highlight the current line in the minimap.
567    ///
568    /// Default: inherits editor line highlights setting
569    pub current_line_highlight: Option<Option<CurrentLineHighlight>>,
570}
571
572/// Forcefully enable or disable the scrollbar for each axis
573#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)]
574pub struct ScrollbarAxesContent {
575    /// When false, forcefully disables the horizontal scrollbar. Otherwise, obey other settings.
576    ///
577    /// Default: true
578    horizontal: Option<bool>,
579
580    /// When false, forcefully disables the vertical scrollbar. Otherwise, obey other settings.
581    ///
582    /// Default: true
583    vertical: Option<bool>,
584}
585
586/// Gutter related settings
587#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
588pub struct GutterContent {
589    /// Whether to show line numbers in the gutter.
590    ///
591    /// Default: true
592    pub line_numbers: Option<bool>,
593    /// Whether to show runnable buttons in the gutter.
594    ///
595    /// Default: true
596    pub runnables: Option<bool>,
597    /// Whether to show breakpoints in the gutter.
598    ///
599    /// Default: true
600    pub breakpoints: Option<bool>,
601    /// Whether to show fold buttons in the gutter.
602    ///
603    /// Default: true
604    pub folds: Option<bool>,
605}
606
607impl EditorSettings {
608    pub fn jupyter_enabled(cx: &App) -> bool {
609        EditorSettings::get_global(cx).jupyter.enabled
610    }
611}
612
613impl Settings for EditorSettings {
614    const KEY: Option<&'static str> = None;
615
616    type FileContent = EditorSettingsContent;
617
618    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> anyhow::Result<Self> {
619        sources.json_merge()
620    }
621
622    fn import_from_vscode(vscode: &VsCodeSettings, current: &mut Self::FileContent) {
623        vscode.enum_setting(
624            "editor.cursorBlinking",
625            &mut current.cursor_blink,
626            |s| match s {
627                "blink" | "phase" | "expand" | "smooth" => Some(true),
628                "solid" => Some(false),
629                _ => None,
630            },
631        );
632        vscode.enum_setting(
633            "editor.cursorStyle",
634            &mut current.cursor_shape,
635            |s| match s {
636                "block" => Some(CursorShape::Block),
637                "block-outline" => Some(CursorShape::Hollow),
638                "line" | "line-thin" => Some(CursorShape::Bar),
639                "underline" | "underline-thin" => Some(CursorShape::Underline),
640                _ => None,
641            },
642        );
643
644        vscode.enum_setting(
645            "editor.renderLineHighlight",
646            &mut current.current_line_highlight,
647            |s| match s {
648                "gutter" => Some(CurrentLineHighlight::Gutter),
649                "line" => Some(CurrentLineHighlight::Line),
650                "all" => Some(CurrentLineHighlight::All),
651                _ => None,
652            },
653        );
654
655        vscode.bool_setting(
656            "editor.selectionHighlight",
657            &mut current.selection_highlight,
658        );
659        vscode.bool_setting("editor.hover.enabled", &mut current.hover_popover_enabled);
660        vscode.u64_setting("editor.hover.delay", &mut current.hover_popover_delay);
661
662        let mut gutter = GutterContent::default();
663        vscode.enum_setting(
664            "editor.showFoldingControls",
665            &mut gutter.folds,
666            |s| match s {
667                "always" | "mouseover" => Some(true),
668                "never" => Some(false),
669                _ => None,
670            },
671        );
672        vscode.enum_setting(
673            "editor.lineNumbers",
674            &mut gutter.line_numbers,
675            |s| match s {
676                "on" | "relative" => Some(true),
677                "off" => Some(false),
678                _ => None,
679            },
680        );
681        if let Some(old_gutter) = current.gutter.as_mut() {
682            if gutter.folds.is_some() {
683                old_gutter.folds = gutter.folds
684            }
685            if gutter.line_numbers.is_some() {
686                old_gutter.line_numbers = gutter.line_numbers
687            }
688        } else {
689            if gutter != GutterContent::default() {
690                current.gutter = Some(gutter)
691            }
692        }
693        if let Some(b) = vscode.read_bool("editor.scrollBeyondLastLine") {
694            current.scroll_beyond_last_line = Some(if b {
695                ScrollBeyondLastLine::OnePage
696            } else {
697                ScrollBeyondLastLine::Off
698            })
699        }
700
701        let mut scrollbar_axes = ScrollbarAxesContent::default();
702        vscode.enum_setting(
703            "editor.scrollbar.horizontal",
704            &mut scrollbar_axes.horizontal,
705            |s| match s {
706                "auto" | "visible" => Some(true),
707                "hidden" => Some(false),
708                _ => None,
709            },
710        );
711        vscode.enum_setting(
712            "editor.scrollbar.vertical",
713            &mut scrollbar_axes.horizontal,
714            |s| match s {
715                "auto" | "visible" => Some(true),
716                "hidden" => Some(false),
717                _ => None,
718            },
719        );
720
721        if scrollbar_axes != ScrollbarAxesContent::default() {
722            let scrollbar_settings = current.scrollbar.get_or_insert_default();
723            let axes_settings = scrollbar_settings.axes.get_or_insert_default();
724
725            if let Some(vertical) = scrollbar_axes.vertical {
726                axes_settings.vertical = Some(vertical);
727            }
728            if let Some(horizontal) = scrollbar_axes.horizontal {
729                axes_settings.horizontal = Some(horizontal);
730            }
731        }
732
733        // TODO: check if this does the int->float conversion?
734        vscode.f32_setting(
735            "editor.cursorSurroundingLines",
736            &mut current.vertical_scroll_margin,
737        );
738        vscode.f32_setting(
739            "editor.mouseWheelScrollSensitivity",
740            &mut current.scroll_sensitivity,
741        );
742        if Some("relative") == vscode.read_string("editor.lineNumbers") {
743            current.relative_line_numbers = Some(true);
744        }
745
746        vscode.enum_setting(
747            "editor.find.seedSearchStringFromSelection",
748            &mut current.seed_search_query_from_cursor,
749            |s| match s {
750                "always" => Some(SeedQuerySetting::Always),
751                "selection" => Some(SeedQuerySetting::Selection),
752                "never" => Some(SeedQuerySetting::Never),
753                _ => None,
754            },
755        );
756        vscode.bool_setting("search.smartCase", &mut current.use_smartcase_search);
757        vscode.enum_setting(
758            "editor.multiCursorModifier",
759            &mut current.multi_cursor_modifier,
760            |s| match s {
761                "ctrlCmd" => Some(MultiCursorModifier::CmdOrCtrl),
762                "alt" => Some(MultiCursorModifier::Alt),
763                _ => None,
764            },
765        );
766
767        vscode.bool_setting(
768            "editor.parameterHints.enabled",
769            &mut current.auto_signature_help,
770        );
771        vscode.bool_setting(
772            "editor.parameterHints.enabled",
773            &mut current.show_signature_help_after_edits,
774        );
775
776        if let Some(use_ignored) = vscode.read_bool("search.useIgnoreFiles") {
777            let search = current.search.get_or_insert_default();
778            search.include_ignored = use_ignored;
779        }
780
781        let mut minimap = MinimapContent::default();
782        let minimap_enabled = vscode.read_bool("editor.minimap.enabled").unwrap_or(true);
783        let autohide = vscode.read_bool("editor.minimap.autohide");
784        if minimap_enabled {
785            if let Some(false) = autohide {
786                minimap.show = Some(ShowMinimap::Always);
787            } else {
788                minimap.show = Some(ShowMinimap::Auto);
789            }
790        } else {
791            minimap.show = Some(ShowMinimap::Never);
792        }
793
794        vscode.enum_setting(
795            "editor.minimap.showSlider",
796            &mut minimap.thumb,
797            |s| match s {
798                "always" => Some(MinimapThumb::Always),
799                "mouseover" => Some(MinimapThumb::Hover),
800                _ => None,
801            },
802        );
803
804        if minimap != MinimapContent::default() {
805            current.minimap = Some(minimap)
806        }
807    }
808}