settings_ui: Fix IEEE 754 floating point error when serializing value to JSON (#40677)
Closes #40556 Release Notes: - settings-ui: Fixed an issue where modifying floating point number fields could result in the values written to the settings file containing IEEE 754 floating point error > [!Note] > Seems like there's another pull request fixing the centered layout in #40661 by normalizing the whole `settings.json` file when updating it. Not sure which is the better way to handle this issue. ## Description This pull request solves the IEEE 754 floating point error when serializing values from settings-ui into `settings.json` by creating a two `serde_helper` to convert the problematic f32 into a formatted two decimal placed f32. Fields currently exists the IEEE 754 error: - Appearance → Unnecessary Code Fade - Editor → Drop Size Target - Window & Layout → Centered Layout Left/Right Padding - Window & Layout → Inactive Opacity ## How to verify ### Unnecessary Code Fade As Is | To Be --- | --- <video src="https://github.com/user-attachments/assets/1bf4bad2-63c5-4b03-ac29-8b6b59569e16" /> | <video src="https://github.com/user-attachments/assets/dadcd4a1-651b-43dd-913f-edae073ceb68" /> ### Drop Size Target As Is | To Be --- | --- <video src="https://github.com/user-attachments/assets/9d5b4173-fcac-44d0-b7fc-772a2e426ef1" /> | <video src="https://github.com/user-attachments/assets/4b5adeaf-e678-494d-bd1b-6c1d55824c43" /> ### Centered Layout Left/Right Padding As Is | To Be --- | --- <video src="https://github.com/user-attachments/assets/33b4e1ff-7ab2-44f7-9e9b-8abad1565d9a" /> | <video src="https://github.com/user-attachments/assets/63d8de9e-28d1-4bd7-a6c9-02452e105486" /> ### Inactive Opacity As Is | To Be --- | --- <video src="https://github.com/user-attachments/assets/a7fe2e72-deb6-41dc-82f3-e2649503b8a4" /> | <video src="https://github.com/user-attachments/assets/993c314f-b6f6-4dcd-8f74-fa357ab063e9" /> --------- Co-authored-by: Ben Kunkle <ben@zed.dev>
This commit is contained in:
@@ -515,6 +515,7 @@ pub struct GitPanelSettingsContent {
|
||||
/// Default width of the panel in pixels.
|
||||
///
|
||||
/// Default: 360
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub default_width: Option<f32>,
|
||||
/// How entry statuses are displayed.
|
||||
///
|
||||
@@ -586,6 +587,7 @@ pub struct NotificationPanelSettingsContent {
|
||||
/// Default width of the panel in pixels.
|
||||
///
|
||||
/// Default: 300
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub default_width: Option<f32>,
|
||||
}
|
||||
|
||||
@@ -603,6 +605,7 @@ pub struct PanelSettingsContent {
|
||||
/// Default width of the panel in pixels.
|
||||
///
|
||||
/// Default: 240
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub default_width: Option<f32>,
|
||||
}
|
||||
|
||||
@@ -777,6 +780,7 @@ pub struct OutlinePanelSettingsContent {
|
||||
/// Customize default width (in pixels) taken by outline panel
|
||||
///
|
||||
/// Default: 240
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub default_width: Option<f32>,
|
||||
/// The position of outline panel
|
||||
///
|
||||
@@ -797,6 +801,7 @@ pub struct OutlinePanelSettingsContent {
|
||||
/// Amount of indentation (in pixels) for nested items.
|
||||
///
|
||||
/// Default: 20
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub indent_size: Option<f32>,
|
||||
/// Whether to reveal it in the outline panel automatically,
|
||||
/// when a corresponding project entry becomes active.
|
||||
|
||||
Reference in New Issue
Block a user