mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
picker: Outline Editor::new
That way crates that use Picker::new do not have to codegen constructor of Editor; tl;dr, 10% of LLVM shaved off of crates like vcs_menu or theme_selector in release mode.
This commit is contained in:
parent
87d3f59515
commit
0755ce6486
@ -58,13 +58,16 @@ impl<D: PickerDelegate> FocusableView for Picker<D> {
|
||||
}
|
||||
}
|
||||
|
||||
fn create_editor(placeholder: Arc<str>, cx: &mut WindowContext<'_>) -> View<Editor> {
|
||||
cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text(placeholder, cx);
|
||||
editor
|
||||
})
|
||||
}
|
||||
impl<D: PickerDelegate> Picker<D> {
|
||||
pub fn new(delegate: D, cx: &mut ViewContext<Self>) -> Self {
|
||||
let editor = cx.new_view(|cx| {
|
||||
let mut editor = Editor::single_line(cx);
|
||||
editor.set_placeholder_text(delegate.placeholder_text(), cx);
|
||||
editor
|
||||
});
|
||||
let editor = create_editor(delegate.placeholder_text(), cx);
|
||||
cx.subscribe(&editor, Self::on_input_editor_event).detach();
|
||||
let mut this = Self {
|
||||
delegate,
|
||||
|
Loading…
Reference in New Issue
Block a user