Allow using context in the placeholder_text method

This commit is contained in:
Kirill Bulatov 2024-02-24 23:26:40 +02:00 committed by Kirill Bulatov
parent cf3b875922
commit c29ea9bdbc
17 changed files with 24 additions and 22 deletions

View file

@ -37,7 +37,7 @@ pub trait PickerDelegate: Sized + 'static {
}
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>);
fn placeholder_text(&self) -> Arc<str>;
fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc<str>;
fn update_matches(&mut self, query: String, cx: &mut ViewContext<Picker<Self>>) -> Task<()>;
// Delegates that support this method (e.g. the CommandPalette) can chose to block on any background
@ -98,7 +98,7 @@ impl<D: PickerDelegate> Picker<D> {
}
fn new(delegate: D, cx: &mut ViewContext<Self>, 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,