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 <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-11 02:13:02 +03:00 committed by Jeremy Soller
parent 4bde45bcdc
commit 9b185c9610

View file

@ -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();