From 9b185c9610c7018c7ad3da028ee7f6a7866cf5a2 Mon Sep 17 00:00:00 2001 From: Mohammad AlSaleh Date: Thu, 11 Jan 2024 02:13:02 +0300 Subject: [PATCH] Sleep for 50ms before sending first `Message::TabNew` This fixes the issue of two tabs being created at startup. Should fix #36. Signed-off-by: Mohammad AlSaleh --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index afa7da9..d4f7708 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use cosmic::{ Application, ApplicationExt, Element, }; use cosmic_text::{Family, Weight, Stretch, fontdb::FaceInfo}; -use std::{any::TypeId, collections::{HashMap, BTreeMap, BTreeSet}, env, process, sync::Mutex}; +use std::{any::TypeId, collections::{HashMap, BTreeMap, BTreeSet}, env, process, sync::Mutex, time::Duration}; use tokio::sync::mpsc; use config::{AppTheme, Config, CONFIG_VERSION}; @@ -1085,6 +1085,10 @@ impl Application for App { let (event_tx, mut event_rx) = mpsc::channel(100); output.send(Message::TermEventTx(event_tx)).await.unwrap(); + + // Avoid creating two tabs at startup + tokio::time::sleep(Duration::from_millis(50)).await; + // Create first terminal tab output.send(Message::TabNew).await.unwrap();