From 0ade84e5e6ef6019cb03b7c435331a4beeba47ac Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Sep 2025 13:53:14 -0600 Subject: [PATCH] Search --- .../remote_editing_collaboration_tests.rs | 4 +- crates/editor/src/editor_settings.rs | 1 + crates/search/src/buffer_search.rs | 10 +++- crates/settings_ui/src/settings_ui.rs | 53 +------------------ crates/vim/src/normal.rs | 12 +++-- 5 files changed, 20 insertions(+), 60 deletions(-) diff --git a/crates/collab/src/tests/remote_editing_collaboration_tests.rs b/crates/collab/src/tests/remote_editing_collaboration_tests.rs index 96e9a0fc03d11a218baac323a8f699ba408cc705..930a8ac972c924a494ec428a0bd2286036c36950 100644 --- a/crates/collab/src/tests/remote_editing_collaboration_tests.rs +++ b/crates/collab/src/tests/remote_editing_collaboration_tests.rs @@ -14,9 +14,7 @@ use gpui::{ use http_client::BlockedHttpClient; use language::{ FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, LanguageRegistry, - language_settings::{ - Formatter, FormatterList, PrettierSettings, SelectedFormatter, language_settings, - }, + language_settings::{Formatter, FormatterList, SelectedFormatter, language_settings}, tree_sitter_typescript, }; use node_runtime::NodeRuntime; diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index f184aed90b85071418a006a36293d235d9a580a4..a6893a10791b1e5ce19d4ad484327d6f16539a74 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -176,6 +176,7 @@ pub struct SearchSettings { pub include_ignored: bool, pub regex: bool, } + impl EditorSettings { pub fn jupyter_enabled(cx: &App) -> bool { EditorSettings::get_global(cx).jupyter.enabled diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 2f046808788a5ccc3af6eed5b341884530ecbc89..dd096cde851b21983be80c5ce64b78338f54d78e 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1480,7 +1480,7 @@ mod tests { use gpui::{Hsla, TestAppContext, UpdateGlobal, VisualTestContext}; use language::{Buffer, Point}; use project::Project; - use settings::SettingsStore; + use settings::{SearchSettingsContent, SettingsStore}; use smol::stream::StreamExt as _; use unindent::Unindent as _; @@ -2867,7 +2867,13 @@ mod tests { cx.update(|cx| { SettingsStore::update_global(cx, |store, cx| { store.update_user_settings(cx, |settings| { - settings.editor.search = Some(search_settings); + settings.editor.search = Some(SearchSettingsContent { + button: Some(search_settings.button), + whole_word: Some(search_settings.whole_word), + case_sensitive: Some(search_settings.case_sensitive), + include_ignored: Some(search_settings.include_ignored), + regex: Some(search_settings.regex), + }); }); }); }); diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 4ba961773df2e605660a841f755be939f64faae0..c5c633e73f90cf4f3c4e5243009ec6f34e905e6e 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -295,57 +295,8 @@ impl SettingsUiTree { // so that we can keep none/skip and still test in CI that all settings have #[cfg(feature = "test-support")] pub fn all_paths(&self, cx: &App) -> Vec> { - fn all_paths_rec( - tree: &[UiEntry], - paths: &mut Vec>, - current_path: &mut Vec, - idx: usize, - cx: &App, - ) { - let child = &tree[idx]; - let mut pushed_path = false; - if let Some(path) = child.path.as_ref() { - current_path.push(path.clone()); - paths.push(current_path.clone()); - pushed_path = true; - } - // todo(settings_ui): handle dynamic nodes here - let selected_descendant_index = child - .dynamic_render - .as_ref() - .map(|dynamic_render| { - read_settings_value_from_path( - SettingsStore::global(cx).raw_default_settings(), - ¤t_path, - ) - .map(|value| (dynamic_render.determine_option)(value, cx)) - }) - .and_then(|selected_descendant_index| { - selected_descendant_index.map(|index| child.nth_descendant_index(tree, index)) - }); - - if let Some(selected_descendant_index) = selected_descendant_index { - // just silently fail if we didn't find a setting value for the path - if let Some(descendant_index) = selected_descendant_index { - all_paths_rec(tree, paths, current_path, descendant_index, cx); - } - } else if let Some(desc_idx) = child.first_descendant_index() { - let mut desc_idx = Some(desc_idx); - while let Some(descendant_index) = desc_idx { - all_paths_rec(&tree, paths, current_path, descendant_index, cx); - desc_idx = tree[descendant_index].next_sibling; - } - } - if pushed_path { - current_path.pop(); - } - } - - let mut paths = Vec::new(); - for &index in &self.root_entry_indices { - all_paths_rec(&self.entries, &mut paths, &mut Vec::new(), index, cx); - } - paths + // todo(settings_ui) this needs to be implemented not in terms of JSON anymore + Vec::default() } } diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index b8d1325a8b19aaa2dcbc2611b2ff66df721c17f3..8d3fec1d64e96bf675e16bed036e0862a664d840 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -1724,8 +1724,8 @@ mod test { async fn test_f_and_t_smartcase(cx: &mut gpui::TestAppContext) { let mut cx = VimTestContext::new(cx, true).await; cx.update_global(|store: &mut SettingsStore, cx| { - store.update_user_settings::(cx, |s| { - s.use_smartcase_find = Some(true); + store.update_user_settings(cx, |s| { + s.vim.get_or_insert_default().use_smartcase_find = Some(true); }); }); @@ -1891,8 +1891,12 @@ mod test { cx.update(|_, cx| { SettingsStore::update_global(cx, |settings, cx| { - settings.update_user_settings::(cx, |settings| { - settings.defaults.preferred_line_length = Some(5); + settings.update_user_settings(cx, |settings| { + settings + .project + .all_languages + .defaults + .preferred_line_length = Some(5); }); }) });