From 8815573101eaade513f22b9172b0016311e05dd2 Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Thu, 19 Feb 2026 10:57:50 -0500 Subject: [PATCH] =?UTF-8?q?buffer=5Fsearch:=20Don=E2=80=99t=20hide=20UI=20?= =?UTF-8?q?icons=20if=20search=20query=20is=20too=20large=20(#49493)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove tracking of editor width in buffer search, removing the behavior where the UI icons used in the search bar would be hidden if the search query need to fill the whole element's width. Closes #49446. Release Notes: - Don’t hide UI icons in buffer search if search query is too large Co-authored-by: dino --- crates/search/src/buffer_search.rs | 83 +++++++++++++----------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 95c5ccae1557d2c8a78c2faeb2f4bf41a9655cd3..7fe9af4ff0f7adfa42796b02b3955aae7a71b2c6 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -13,7 +13,7 @@ use crate::{ use any_vec::AnyVec; use collections::HashMap; use editor::{ - DisplayPoint, Editor, EditorSettings, MultiBufferOffset, SplittableEditor, ToggleSplitDiff, + Editor, EditorSettings, MultiBufferOffset, SplittableEditor, ToggleSplitDiff, actions::{Backtab, FoldAll, Tab, ToggleFoldAll, UnfoldAll}, }; use futures::channel::oneshot; @@ -91,8 +91,6 @@ pub struct BufferSearchBar { replace_enabled: bool, selection_search_enabled: Option, scroll_handle: ScrollHandle, - editor_scroll_handle: ScrollHandle, - editor_needed_width: Pixels, regex_language: Option>, splittable_editor: Option>, _splittable_editor_subscription: Option, @@ -264,8 +262,6 @@ impl Render for BufferSearchBar { let narrow_mode = self.scroll_handle.bounds().size.width / window.rem_size() < 340. / BASE_REM_SIZE_IN_PX; - let hide_inline_icons = self.editor_needed_width - > self.editor_scroll_handle.bounds().size.width - window.rem_size() * 6.; let workspace::searchable::SearchOptions { case, @@ -331,36 +327,39 @@ impl Render for BufferSearchBar { }; let query_column = input_style - .id("editor-scroll") - .track_scroll(&self.editor_scroll_handle) - .child(render_text_input(&self.query_editor, color_override, cx)) - .when(!hide_inline_icons, |div| { - div.child( - h_flex() - .gap_1() - .when(case, |div| { - div.child(SearchOption::CaseSensitive.as_button( - self.search_options, - SearchSource::Buffer, - focus_handle.clone(), - )) - }) - .when(word, |div| { - div.child(SearchOption::WholeWord.as_button( - self.search_options, - SearchSource::Buffer, - focus_handle.clone(), - )) - }) - .when(regex, |div| { - div.child(SearchOption::Regex.as_button( - self.search_options, - SearchSource::Buffer, - focus_handle.clone(), - )) - }), - ) - }); + .child( + div() + .flex_1() + .min_w(px(0.)) + .overflow_hidden() + .child(render_text_input(&self.query_editor, color_override, cx)), + ) + .child( + h_flex() + .flex_none() + .gap_1() + .when(case, |div| { + div.child(SearchOption::CaseSensitive.as_button( + self.search_options, + SearchSource::Buffer, + focus_handle.clone(), + )) + }) + .when(word, |div| { + div.child(SearchOption::WholeWord.as_button( + self.search_options, + SearchSource::Buffer, + focus_handle.clone(), + )) + }) + .when(regex, |div| { + div.child(SearchOption::Regex.as_button( + self.search_options, + SearchSource::Buffer, + focus_handle.clone(), + )) + }), + ); let mode_column = h_flex() .gap_1() @@ -890,8 +889,6 @@ impl BufferSearchBar { replace_enabled: false, selection_search_enabled: None, scroll_handle: ScrollHandle::new(), - editor_scroll_handle: ScrollHandle::new(), - editor_needed_width: px(0.), regex_language: None, splittable_editor: None, _splittable_editor_subscription: None, @@ -1376,7 +1373,7 @@ impl BufferSearchBar { fn on_query_editor_event( &mut self, - editor: &Entity, + _editor: &Entity, event: &editor::EditorEvent, window: &mut Window, cx: &mut Context, @@ -1389,16 +1386,6 @@ impl BufferSearchBar { self.clear_matches(window, cx); let search = self.update_matches(false, true, window, cx); - let width = editor.update(cx, |editor, cx| { - let text_layout_details = editor.text_layout_details(window, cx); - let snapshot = editor.snapshot(window, cx).display_snapshot; - - snapshot.x_for_display_point(snapshot.max_point(), &text_layout_details) - - snapshot.x_for_display_point(DisplayPoint::zero(), &text_layout_details) - }); - self.editor_needed_width = width; - cx.notify(); - cx.spawn_in(window, async move |this, cx| { if search.await.is_ok() { this.update_in(cx, |this, window, cx| {