From 879b5521750b4d918c65cf9fde051ff404fd5b54 Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Tue, 26 Aug 2025 21:33:28 +0300 Subject: [PATCH 1/2] dont update search modes upon dismiss --- crates/search/src/buffer_search.rs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index a38dc8c35b..0feb23c8ed 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -111,7 +111,6 @@ pub struct BufferSearchBar { pending_search: Option>, search_options: SearchOptions, default_options: SearchOptions, - configured_options: SearchOptions, query_error: Option, dismissed: bool, search_history: SearchHistory, @@ -653,7 +652,6 @@ impl BufferSearchBar { active_match_index: None, searchable_items_with_matches: Default::default(), default_options: search_options, - configured_options: search_options, search_options, pending_search: None, query_error: None, @@ -749,16 +747,6 @@ impl BufferSearchBar { return false; }; - self.configured_options = - SearchOptions::from_settings(&EditorSettings::get_global(cx).search); - if self.dismissed - && (self.configured_options != self.default_options - || self.configured_options != self.search_options) - { - self.search_options = self.configured_options; - self.default_options = self.configured_options; - } - self.dismissed = false; self.adjust_query_regex_language(cx); handle.search_bar_visibility_changed(true, window, cx); @@ -2750,11 +2738,6 @@ mod tests { "Search bar should be present and visible" ); search_bar.deploy(&deploy, window, cx); - assert_eq!( - search_bar.configured_options, - SearchOptions::NONE, - "Should have configured search options matching the settings" - ); assert_eq!( search_bar.search_options, SearchOptions::WHOLE_WORD, @@ -2800,11 +2783,6 @@ mod tests { ); search_bar.deploy(&deploy, window, cx); - assert_eq!( - search_bar.configured_options, - SearchOptions::CASE_SENSITIVE, - "Should have configured search options matching the settings" - ); assert_eq!( search_bar.search_options, SearchOptions::REGEX | SearchOptions::WHOLE_WORD, From b924f57f23feeade037f3fad0d40b74b8aba61ae Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Tue, 26 Aug 2025 21:53:02 +0300 Subject: [PATCH 2/2] make tests match new behavior the last stage of the test checks for the behavior that we are removing --- crates/search/src/buffer_search.rs | 38 +++--------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 0feb23c8ed..a3e64e5df5 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -2748,15 +2748,15 @@ mod tests { search_bar.deploy(&deploy, window, cx); assert_eq!( search_bar.search_options, - SearchOptions::NONE, - "After hiding and showing the search bar, default options should be used" + SearchOptions::WHOLE_WORD, + "After hiding and showing the search bar, options should be preserved" ); search_bar.toggle_search_option(SearchOptions::REGEX, window, cx); search_bar.toggle_search_option(SearchOptions::WHOLE_WORD, window, cx); assert_eq!( search_bar.search_options, - SearchOptions::REGEX | SearchOptions::WHOLE_WORD, + SearchOptions::REGEX, "Should enable the options toggled" ); assert!( @@ -2764,38 +2764,6 @@ mod tests { "Search bar should be present and visible" ); }); - - update_search_settings( - SearchSettings { - button: true, - whole_word: false, - case_sensitive: true, - include_ignored: false, - regex: false, - }, - cx, - ); - search_bar.update_in(cx, |search_bar, window, cx| { - assert_eq!( - search_bar.search_options, - SearchOptions::REGEX | SearchOptions::WHOLE_WORD, - "Should have no search options enabled by default" - ); - - search_bar.deploy(&deploy, window, cx); - assert_eq!( - search_bar.search_options, - SearchOptions::REGEX | SearchOptions::WHOLE_WORD, - "Toggling a non-dismissed search bar with custom options should not change the default options" - ); - search_bar.dismiss(&Dismiss, window, cx); - search_bar.deploy(&deploy, window, cx); - assert_eq!( - search_bar.search_options, - SearchOptions::CASE_SENSITIVE, - "After hiding and showing the search bar, default options should be used" - ); - }); } fn update_search_settings(search_settings: SearchSettings, cx: &mut TestAppContext) {