Quit from neovim - quits application

This commit is contained in:
daa84 2016-05-05 17:27:45 +03:00
parent 1a0adf0a82
commit 4e0d3e2e5a

View File

@ -13,6 +13,8 @@ mod ui_model;
mod ui; mod ui;
mod input; mod input;
use std::thread;
fn main() { fn main() {
gtk::init().expect("Failed to initialize GTK"); gtk::init().expect("Failed to initialize GTK");
ui::UI.with(|ui_cell| { ui::UI.with(|ui_cell| {
@ -20,8 +22,20 @@ fn main() {
ui.init(); ui.init();
nvim::initialize(&mut *ui).expect("Can't start nvim instance"); nvim::initialize(&mut *ui).expect("Can't start nvim instance");
guard_dispatch_thread(&mut *ui);
}); });
gtk::main(); 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)
});
});
}