Refactor SearchSettings (#17550)

Related to #17179.

Simplify handling of search settings since there is no requirement to
watch for settings.json changes and update search panels while they are
opened.

Attn: @SomeoneToIgnore 

Per our discussion. Ran test on search crate. Ran `cargo fmt`.

Release Notes:

- N/A
This commit is contained in:
thataboy 2024-09-07 16:58:28 -07:00 committed by GitHub
parent 63188b6754
commit 894866da94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 32 deletions

View file

@ -9,7 +9,7 @@ use any_vec::AnyVec;
use collections::HashMap;
use editor::{
actions::{Tab, TabPrev},
DisplayPoint, Editor, EditorElement, EditorSettings, EditorStyle, SearchSettings,
DisplayPoint, Editor, EditorElement, EditorSettings, EditorStyle,
};
use futures::channel::oneshot;
use gpui::{
@ -22,7 +22,7 @@ use project::{
search_history::{SearchHistory, SearchHistoryCursor},
};
use serde::Deserialize;
use settings::{Settings, SettingsStore};
use settings::Settings;
use std::sync::Arc;
use theme::ThemeSettings;
@ -96,7 +96,6 @@ pub struct BufferSearchBar {
scroll_handle: ScrollHandle,
editor_scroll_handle: ScrollHandle,
editor_needed_width: Pixels,
_subscriptions: Vec<Subscription>,
}
impl BufferSearchBar {
@ -506,11 +505,7 @@ impl BufferSearchBar {
cx.subscribe(&replacement_editor, Self::on_replacement_editor_event)
.detach();
let search_options = SearchOptions::from_settings(&SearchSettings::get_global(cx));
let settings_subscription = cx.observe_global::<SettingsStore>(move |this, cx| {
this.default_options = SearchOptions::from_settings(&SearchSettings::get_global(cx));
});
let search_options = SearchOptions::from_settings(&EditorSettings::get_global(cx).search);
Self {
query_editor,
@ -537,7 +532,6 @@ impl BufferSearchBar {
scroll_handle: ScrollHandle::new(),
editor_scroll_handle: ScrollHandle::new(),
editor_needed_width: px(0.),
_subscriptions: vec![settings_subscription],
}
}
@ -610,6 +604,9 @@ impl BufferSearchBar {
let Some(handle) = self.active_searchable_item.as_ref() else {
return false;
};
self.default_options = SearchOptions::from_settings(&EditorSettings::get_global(cx).search);
if self.default_options != self.search_options {
self.search_options = self.default_options;
}

View file

@ -4,7 +4,6 @@ use editor::SearchSettings;
use gpui::{actions, Action, AppContext, IntoElement};
use project::search::SearchQuery;
pub use project_search::ProjectSearchView;
use settings::Settings;
use ui::{prelude::*, Tooltip};
use ui::{ButtonStyle, IconButton};
use workspace::notifications::NotificationId;
@ -15,7 +14,6 @@ pub mod project_search;
pub(crate) mod search_bar;
pub fn init(cx: &mut AppContext) {
SearchSettings::register(cx);
menu::init();
buffer_search::init(cx);
project_search::init(cx);