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