diff --git a/crates/collab_ui/src/collab_panel/channel_modal.rs b/crates/collab_ui/src/collab_panel/channel_modal.rs index 501524501e63340faabe453f0e285b885e716d0e..54e564590e26e2a685dfcbcf6955f55e60e6a8e7 100644 --- a/crates/collab_ui/src/collab_panel/channel_modal.rs +++ b/crates/collab_ui/src/collab_panel/channel_modal.rs @@ -266,7 +266,7 @@ pub struct ChannelModalDelegate { impl PickerDelegate for ChannelModalDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Search collaborator by username...".into() } diff --git a/crates/collab_ui/src/collab_panel/contact_finder.rs b/crates/collab_ui/src/collab_panel/contact_finder.rs index 6a1932a843b07b056d0624276258fa2413d123dc..ff58c833f139e93cc752ff300cd5fefa0165473e 100644 --- a/crates/collab_ui/src/collab_panel/contact_finder.rs +++ b/crates/collab_ui/src/collab_panel/contact_finder.rs @@ -84,7 +84,7 @@ impl PickerDelegate for ContactFinderDelegate { self.selected_index = ix; } - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Search collaborator by username...".into() } diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index e7edf393ffa59cc59d1d081bda15861c2cf4762c..98dd3bcf751d88d0d399a49588134e9d373098d3 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -231,7 +231,7 @@ impl CommandPaletteDelegate { impl PickerDelegate for CommandPaletteDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Execute a command...".into() } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0bcf55468e564958b6789eb7fe920e60cf54ac16..f32273b6e375b21cf2836e77c36ddddf8070791e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1749,7 +1749,7 @@ impl Editor { self.completion_provider = Some(hub); } - pub fn placeholder_text(&self) -> Option<&str> { + pub fn placeholder_text(&self, _cx: &mut WindowContext) -> Option<&str> { self.placeholder_text.as_deref() } @@ -9618,7 +9618,7 @@ impl EditorSnapshot { self.is_focused } - pub fn placeholder_text(&self) -> Option<&Arc> { + pub fn placeholder_text(&self, _cx: &mut WindowContext) -> Option<&Arc> { self.placeholder_text.as_ref() } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 099c52d7fd35d4041878a5cc9cd7fe657b61bc7b..654b8be4b6e5e62c22be2d6d1c51c1a7e8d68349 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1904,7 +1904,7 @@ impl EditorElement { rows: Range, line_number_layouts: &[Option], snapshot: &EditorSnapshot, - cx: &ViewContext, + cx: &mut ViewContext, ) -> Vec { if rows.start >= rows.end { return Vec::new(); @@ -1914,7 +1914,7 @@ impl EditorElement { if snapshot.is_empty() { let font_size = self.style.text.font_size.to_pixels(cx.rem_size()); let placeholder_color = cx.theme().colors().text_placeholder; - let placeholder_text = snapshot.placeholder_text(); + let placeholder_text = snapshot.placeholder_text(cx); let placeholder_lines = placeholder_text .as_ref() diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index fc8e5d1d995386840e725c6c7b00d35c953857d6..eb57afece18c1fd1ba743232a34e1b03c84922f3 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -663,7 +663,7 @@ impl FileFinderDelegate { impl PickerDelegate for FileFinderDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Search project files...".into() } diff --git a/crates/language_selector/src/language_selector.rs b/crates/language_selector/src/language_selector.rs index 0a3faffbeee95d352a768a38fe1a11671174df64..6bdf5a67d00a282dae34882661983da45cadf3a2 100644 --- a/crates/language_selector/src/language_selector.rs +++ b/crates/language_selector/src/language_selector.rs @@ -120,7 +120,7 @@ impl LanguageSelectorDelegate { impl PickerDelegate for LanguageSelectorDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Select a language...".into() } diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index a078ad6a7c055b61117134d79b99072cf3142a0c..627c4a0de24dba7f4d4068d3a3681468065e6217 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -157,7 +157,7 @@ impl OutlineViewDelegate { impl PickerDelegate for OutlineViewDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Search buffer symbols...".into() } diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index 1ade6eed1f5e7e0b40a602133c1adcd044f984a8..55ee34003599d5454f6a535ec63b4424ad32072e 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -37,7 +37,7 @@ pub trait PickerDelegate: Sized + 'static { } fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext>); - fn placeholder_text(&self) -> Arc; + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc; fn update_matches(&mut self, query: String, cx: &mut ViewContext>) -> Task<()>; // Delegates that support this method (e.g. the CommandPalette) can chose to block on any background @@ -98,7 +98,7 @@ impl Picker { } fn new(delegate: D, cx: &mut ViewContext, is_uniform: bool) -> Self { - let editor = create_editor(delegate.placeholder_text(), cx); + let editor = create_editor(delegate.placeholder_text(cx), cx); cx.subscribe(&editor, Self::on_input_editor_event).detach(); let mut this = Self { delegate, diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index bd5b2e64c4a06fb1349a405665d582584f8f18f2..61cc7059a64818076f324eaa1c0f88e4385c6b37 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -2,7 +2,7 @@ use editor::{scroll::Autoscroll, styled_runs_for_code_label, Bias, Editor}; use fuzzy::{StringMatch, StringMatchCandidate}; use gpui::{ actions, rems, AppContext, DismissEvent, FontWeight, Model, ParentElement, StyledText, Task, - View, ViewContext, WeakView, + View, ViewContext, WeakView, WindowContext, }; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; @@ -106,7 +106,7 @@ impl ProjectSymbolsDelegate { impl PickerDelegate for ProjectSymbolsDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Search project symbols...".into() } diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index db4e73d6b20f80a7778e111c66616970c6131c83..314eccccacacfd7dea10d40992cba2923e64f739 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -146,7 +146,7 @@ impl EventEmitter for RecentProjectsDelegate {} impl PickerDelegate for RecentProjectsDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { Arc::from(format!( "`{:?}` reuses the window, `{:?}` opens in new", menu::Confirm, diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 597e8a479720a209cd344b46a8e3852021572632..84da37155c036c9ac82cc2cbf8a10b7b91341243 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -127,7 +127,9 @@ impl Render for BufferSearchBar { let supported_options = self.supported_options(); - if self.query_editor.read(cx).placeholder_text().is_none() { + if self.query_editor.update(cx, |query_editor, cx| { + query_editor.placeholder_text(cx).is_none() + }) { let query_focus_handle = self.query_editor.focus_handle(cx); let up_keystrokes = cx .bindings_for_action_in(&PreviousHistoryQuery {}, &query_focus_handle) diff --git a/crates/storybook/src/stories/picker.rs b/crates/storybook/src/stories/picker.rs index cdc0a0907ed7719c24940d203f5ee9e76d0367dd..5d4c8dfc897a45d72fc72a262e093ff4623eddfb 100644 --- a/crates/storybook/src/stories/picker.rs +++ b/crates/storybook/src/stories/picker.rs @@ -41,7 +41,7 @@ impl PickerDelegate for Delegate { self.candidates.len() } - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Test".into() } diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rs index de5cc5d5968110b4bdb9e385ac3e1d33f15d1321..47724f80b921cb81a2a0528ad4c99850ce760145 100644 --- a/crates/tasks_ui/src/modal.rs +++ b/crates/tasks_ui/src/modal.rs @@ -9,7 +9,7 @@ use gpui::{ use picker::{Picker, PickerDelegate}; use project::Inventory; use task::{oneshot_source::OneshotSource, Task}; -use ui::{v_flex, HighlightedLabel, ListItem, ListItemSpacing, Selectable}; +use ui::{v_flex, HighlightedLabel, ListItem, ListItemSpacing, Selectable, WindowContext}; use util::ResultExt; use workspace::{ModalView, Workspace}; @@ -115,7 +115,7 @@ impl PickerDelegate for TasksModalDelegate { self.selected_index = ix; } - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { self.placeholder_text.clone() } diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index 2ad1085f66c090f6280cf4a6f484f2d036e52d65..c0008e90d6c2f224837a7ee5d459af8cc3dbb536 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -153,7 +153,7 @@ impl ThemeSelectorDelegate { impl PickerDelegate for ThemeSelectorDelegate { type ListItem = ui::ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Select Theme...".into() } diff --git a/crates/vcs_menu/src/lib.rs b/crates/vcs_menu/src/lib.rs index 645c3e712828f0e8d6fb1e9b3e5561288b4c9270..55cfcda94428fefbb16ff11aef623170ff7cd140 100644 --- a/crates/vcs_menu/src/lib.rs +++ b/crates/vcs_menu/src/lib.rs @@ -135,7 +135,7 @@ impl BranchListDelegate { impl PickerDelegate for BranchListDelegate { type ListItem = ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Select branch...".into() } diff --git a/crates/welcome/src/base_keymap_picker.rs b/crates/welcome/src/base_keymap_picker.rs index c6acd95a96131b17269ab5be4a58073ceb51d5bc..aa65051c0b4f96d1861132682b20fc8c43f72e9b 100644 --- a/crates/welcome/src/base_keymap_picker.rs +++ b/crates/welcome/src/base_keymap_picker.rs @@ -99,7 +99,7 @@ impl BaseKeymapSelectorDelegate { impl PickerDelegate for BaseKeymapSelectorDelegate { type ListItem = ui::ListItem; - fn placeholder_text(&self) -> Arc { + fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { "Select a base keymap...".into() }