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| {