settings_ui: Add dropdown component + other fixes (#38909)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Ben Kunkle
2025-09-25 15:59:34 -04:00
committed by GitHub
parent ae036f8ead
commit 48aac2a746
8 changed files with 162 additions and 87 deletions
+6
View File
@@ -870,6 +870,12 @@ impl From<bool> for SaturatingBool {
}
}
impl From<SaturatingBool> for bool {
fn from(value: SaturatingBool) -> bool {
value.0
}
}
impl merge_from::MergeFrom for SaturatingBool {
fn merge_from(&mut self, other: &Self) {
self.0 |= other.0
+12 -1
View File
@@ -485,7 +485,18 @@ pub enum ScrollBeyondLastLine {
/// The shape of a selection cursor.
#[derive(
Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom,
Copy,
Clone,
Debug,
Default,
Serialize,
Deserialize,
PartialEq,
Eq,
JsonSchema,
MergeFrom,
strum::VariantArray,
strum::VariantNames,
)]
#[serde(rename_all = "snake_case")]
pub enum CursorShape {
@@ -217,6 +217,7 @@ pub enum ShowScrollbar {
Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom,
)]
#[serde(rename_all = "snake_case")]
// todo() -> combine with CursorShape
pub enum CursorShapeContent {
/// Cursor is a block like `█`.
#[default]
+2 -30
View File
@@ -7,7 +7,7 @@ use futures::{
channel::{mpsc, oneshot},
future::LocalBoxFuture,
};
use gpui::{App, AsyncApp, BorrowAppContext, Global, SharedString, Task, UpdateGlobal};
use gpui::{App, AsyncApp, BorrowAppContext, Global, Task, UpdateGlobal};
use paths::{EDITORCONFIG_NAME, local_settings_file_relative_path, task_file_name};
use schemars::{JsonSchema, json_schema};
@@ -34,7 +34,7 @@ use crate::{
ActiveSettingsProfileName, FontFamilyName, IconThemeName, LanguageSettingsContent,
LanguageToSettingsMap, SettingsJsonSchemaParams, ThemeName, VsCodeSettings, WorktreeId,
merge_from::MergeFrom,
parse_json_with_comments, replace_value_in_json_text,
parse_json_with_comments,
settings_content::{
ExtensionsSettingsContent, ProjectSettingsContent, SettingsContent, UserSettingsContent,
},
@@ -439,34 +439,6 @@ impl SettingsStore {
return rx;
}
pub fn update_settings_file_at_path(
&self,
fs: Arc<dyn Fs>,
path: &[impl AsRef<str>],
new_value: serde_json::Value,
) -> oneshot::Receiver<Result<()>> {
let key_path = path
.into_iter()
.map(AsRef::as_ref)
.map(SharedString::new)
.collect::<Vec<_>>();
let update = move |mut old_text: String, cx: AsyncApp| {
cx.read_global(|store: &SettingsStore, _cx| {
// todo(settings_ui) use `update_value_in_json_text` for merging new and old objects with comment preservation, needs old value though...
let (range, replacement) = replace_value_in_json_text(
&old_text,
key_path.as_slice(),
store.json_tab_size(),
Some(&new_value),
None,
);
old_text.replace_range(range, &replacement);
old_text
})
};
self.update_settings_file_inner(fs, update)
}
pub fn update_settings_file(
&self,
fs: Arc<dyn Fs>,