diff --git a/src/main.rs b/src/main.rs index 5e0a2bb..9bf0351 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,8 @@ mod ui_model; mod ui; mod input; +use std::thread; + fn main() { gtk::init().expect("Failed to initialize GTK"); ui::UI.with(|ui_cell| { @@ -20,8 +22,20 @@ fn main() { ui.init(); nvim::initialize(&mut *ui).expect("Can't start nvim instance"); + + guard_dispatch_thread(&mut *ui); }); gtk::main(); } +fn guard_dispatch_thread(ui: &mut ui::Ui) { + let guard = ui.nvim().session.take_dispatch_guard(); + thread::spawn(move || { + guard.join().expect("Can't join dispatch thread"); + glib::idle_add(move || { + gtk::main_quit(); + glib::Continue(false) + }); + }); +}