diff options
author | Gokul Soumya | 2022-03-03 01:14:50 +0000 |
---|---|---|
committer | GitHub | 2022-03-03 01:14:50 +0000 |
commit | 5c810e5e52a3409a5e70aeae14e6f28dd440c681 (patch) | |
tree | 166b82b45dcab93b9febb8c3f3dfec9fed77cf00 /helix-term/src/commands.rs | |
parent | 86b1236b46286b64da2c030a36e8f38ddad0a1d0 (diff) |
Fix bug with auto replacing components in compositor (#1711)
* Fix bug with auto replacing components in compositor
This was last known to be working with 5995568c at the
time of commit, but now doesn't work with latest rust
stable.
The issue probably stems from using
std::any::type_name() for finding a component in the
compositor, for which the docs explicitly warn against
considering it as a unique identifier for types.
`replace_or_push()` takes a boxed `Component` and
passes it to `find_id()` which compares this with a
bare Component. `type_name()` returns `Box<T>` for
the former and `T` for latter and we have a false
negative. This has been solved by using a generics
instead of trait objects to pass in a `T: Component`
and then use it for comparison.
I'm not exactly sure how this worked fine at the
time of commit of 5995568c; maybe the internal
implementation of `type_name()` changed to properly
indicate indirection with Box.
* Do not compare by type name in compositor find_id
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 74d4c8d7..b7942f8d 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) }; |