diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 74d4c8d71..b7942f8d9 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2980,7 +2980,7 @@ pub mod cmd { Box::new(move |editor: &mut Editor, compositor: &mut Compositor| { let contents = ui::Markdown::new(contents, editor.syn_loader.clone()); let popup = Popup::new("hover", contents).auto_close(true); - compositor.replace_or_push("hover", Box::new(popup)); + compositor.replace_or_push("hover", popup); }); Ok(call) }; diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index df1bfb64a..aa7fa1c87 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -254,7 +254,7 @@ pub fn code_action(cx: &mut Context) { vertical: 1, horizontal: 1, }); - compositor.replace_or_push("code-action", Box::new(popup)); + compositor.replace_or_push("code-action", popup); }, ) } @@ -637,7 +637,7 @@ pub fn hover(cx: &mut Context) { let contents = ui::Markdown::new(contents, editor.syn_loader.clone()); let popup = Popup::new("hover", contents).auto_close(true); - compositor.replace_or_push("hover", Box::new(popup)); + compositor.replace_or_push("hover", popup); } }, ); diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index 2f80de008..4f988acee 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -128,11 +128,11 @@ impl Compositor { /// Replace a component that has the given `id` with the new layer and if /// no component is found, push the layer normally. - pub fn replace_or_push(&mut self, id: &'static str, layer: Box) { + pub fn replace_or_push(&mut self, id: &'static str, layer: T) { if let Some(component) = self.find_id(id) { *component = layer; } else { - self.push(layer) + self.push(Box::new(layer)) } } @@ -221,10 +221,9 @@ impl Compositor { } pub fn find_id(&mut self, id: &'static str) -> Option<&mut T> { - let type_name = std::any::type_name::(); self.layers .iter_mut() - .find(|component| component.type_name() == type_name && component.id() == Some(id)) + .find(|component| component.id() == Some(id)) .and_then(|component| component.as_any_mut().downcast_mut()) } }