editor: Add sticky scroll (#42242)
Closes #5344 https://github.com/user-attachments/assets/37ec58b0-7cf6-4eea-9b34-dccf03d3526b Release Notes: - Added a setting to stick scopes to the top of the editor --------- Co-authored-by: KyleBarton <kjb@initialcapacity.io> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
co-authored by
KyleBarton
Conrad Irwin
parent
d896af2f15
commit
aa6270e658
@@ -96,6 +96,10 @@ pub struct EditorSettingsContent {
|
||||
/// Default: 4.0
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub fast_scroll_sensitivity: Option<f32>,
|
||||
/// Settings for sticking scopes to the top of the editor.
|
||||
///
|
||||
/// Default: sticky scroll is disabled
|
||||
pub sticky_scroll: Option<StickyScrollContent>,
|
||||
/// Whether the line numbers on editors gutter are relative or not.
|
||||
/// When "enabled" shows relative number of buffer lines, when "wrapped" shows
|
||||
/// relative number of display lines.
|
||||
@@ -312,6 +316,16 @@ pub struct ScrollbarContent {
|
||||
pub axes: Option<ScrollbarAxesContent>,
|
||||
}
|
||||
|
||||
/// Sticky scroll related settings
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
|
||||
pub struct StickyScrollContent {
|
||||
/// Whether sticky scroll is enabled.
|
||||
///
|
||||
/// Default: false
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
/// Minimap related settings
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
|
||||
|
||||
@@ -255,6 +255,7 @@ impl VsCodeSettings {
|
||||
excerpt_context_lines: None,
|
||||
expand_excerpt_lines: None,
|
||||
fast_scroll_sensitivity: self.read_f32("editor.fastScrollSensitivity"),
|
||||
sticky_scroll: self.sticky_scroll_content(),
|
||||
go_to_definition_fallback: None,
|
||||
gutter: self.gutter_content(),
|
||||
hide_mouse: None,
|
||||
@@ -303,6 +304,12 @@ impl VsCodeSettings {
|
||||
}
|
||||
}
|
||||
|
||||
fn sticky_scroll_content(&self) -> Option<StickyScrollContent> {
|
||||
skip_default(StickyScrollContent {
|
||||
enabled: self.read_bool("editor.stickyScroll.enabled"),
|
||||
})
|
||||
}
|
||||
|
||||
fn gutter_content(&self) -> Option<GutterContent> {
|
||||
skip_default(GutterContent {
|
||||
line_numbers: self.read_enum("editor.lineNumbers", |s| match s {
|
||||
|
||||
Reference in New Issue
Block a user