From e0acbd0b9f7f4e78ab848ec36c3ab73c8255a1be Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Fri, 17 Jan 2020 16:06:20 -0800 Subject: [PATCH] fix crash with error in startup script --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8ffd37f..d0de47f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,7 @@ async fn start_nvim(editor: Arc>, mut receiver: UnboundedReceiver< nvim.ui_attach(INITIAL_WIDTH as i64, INITIAL_HEIGHT as i64, &options).await .unwrap_or_explained_panic("Could not attach.", "Could not attach ui to neovim process"); + let nvim = Arc::new(nvim); loop { let mut commands = Vec::new(); let mut resize_command = None; @@ -102,9 +103,12 @@ async fn start_nvim(editor: Arc>, mut receiver: UnboundedReceiver< commands.push(resize_command); } - for ui_command in commands.iter() { - ui_command.execute(&nvim).await; - } + let nvim = nvim.clone(); + tokio::spawn(async move { + for ui_command in commands.into_iter() { + ui_command.execute(&nvim).await; + } + }); } }