Ensure that on_release callbacks are called even if view outlives its window

This commit is contained in:
Max Brunsfeld 2023-12-20 16:01:52 -08:00
parent e1a4e8ea16
commit 5e7c74c7b6
5 changed files with 27 additions and 19 deletions

View file

@ -13,7 +13,7 @@ pub fn init(cx: &mut AppContext) {
.detach();
let id = cx.view().entity_id();
cx.on_release(move |_, cx| released(id, cx)).detach();
cx.on_release(move |_, _, cx| released(id, cx)).detach();
})
.detach();
}
@ -51,8 +51,8 @@ fn blurred(editor: View<Editor>, cx: &mut WindowContext) {
});
}
fn released(entity_id: EntityId, cx: &mut WindowContext) {
Vim::update(cx, |vim, _| {
fn released(entity_id: EntityId, cx: &mut AppContext) {
cx.update_global(|vim: &mut Vim, _| {
if vim
.active_editor
.as_ref()