settings ui: Add numeric steppers to settings UI (#39491)

This PR adds the numeric stepper component to the settings ui and
implements some settings that rely on this component as well.

I also switched {buffer/ui}_font_weight to the `gpui::FontWeight` type
and added a manual implementation of the Schemars trait. This allows Zed
to send min, max, and default information to the JSON LSP when a user is
manually editing the settings file.

The numeric stepper elements added to the settings ui are below:
- ui font size
- ui font weight
- Buffer font size
- Buffer font weight 
- Scroll sensitivity
- Fast scroll sensitivity
- Vertical scroll margin
- Horizontal scroll margin
- Inline blame padding 
- Inline blame delay
- Inline blame min column
- Unnecessary code fade
- Tab Size
- Hover popover delay

Release Notes:

- N/A
This commit is contained in:
Anthony Eid
2025-10-06 10:06:33 +00:00
committed by GitHub
parent c26937a848
commit d2b91eb2bc
11 changed files with 501 additions and 137 deletions
+32 -2
View File
@@ -19,7 +19,7 @@ use crate::{
use anyhow::{Context as _, anyhow};
use collections::FxHashMap;
use core::fmt;
use derive_more::Deref;
use derive_more::{Add, Deref, FromStr, Sub};
use itertools::Itertools;
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
use smallvec::{SmallVec, smallvec};
@@ -605,9 +605,22 @@ impl DerefMut for LineWrapperHandle {
/// The degree of blackness or stroke thickness of a font. This value ranges from 100.0 to 900.0,
/// with 400.0 as normal.
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Serialize, Deserialize, JsonSchema)]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Serialize, Deserialize, Add, Sub, FromStr)]
#[serde(transparent)]
pub struct FontWeight(pub f32);
impl Display for FontWeight {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<f32> for FontWeight {
fn from(weight: f32) -> Self {
FontWeight(weight)
}
}
impl Default for FontWeight {
#[inline]
fn default() -> FontWeight {
@@ -657,6 +670,23 @@ impl FontWeight {
];
}
impl schemars::JsonSchema for FontWeight {
fn schema_name() -> std::borrow::Cow<'static, str> {
"FontWeight".into()
}
fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
use schemars::json_schema;
json_schema!({
"type": "number",
"minimum": Self::THIN,
"maximum": Self::BLACK,
"default": Self::default(),
"description": "Font weight value between 100 (thin) and 900 (black)"
})
}
}
/// Allows italic or oblique faces to be selected.
#[derive(Clone, Copy, Eq, PartialEq, Debug, Hash, Default, Serialize, Deserialize, JsonSchema)]
pub enum FontStyle {