From 52e857aa5ab3301d2e567c6ef7f568a25f363357 Mon Sep 17 00:00:00 2001 From: Penwing Date: Thu, 25 Jan 2024 13:16:39 +0100 Subject: [PATCH] exit properly after last tab closes --- README.md | 2 +- src/calcifer.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cce0137..616ef39 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,6 @@ Max tabs 8 => 20 Max framerate => 30 fps (less cpu usage) # 1.1.0 : -Added close tab and refresh confirm prompt +Added confirm prompt if unsaved Async terminal ! Better Ui \ No newline at end of file diff --git a/src/calcifer.rs b/src/calcifer.rs index 4802b99..ee2d6e9 100644 --- a/src/calcifer.rs +++ b/src/calcifer.rs @@ -142,11 +142,15 @@ impl Calcifer { ui.style_mut().visuals.override_text_color = None; if ui.link("X").clicked() && !self.close_tab_confirm.visible { - if tab.saved { - self.delete_tab(index); + if self.tabs.len() > 1 { + if tab.saved { + self.delete_tab(index); + } else { + self.close_tab_confirm.ask(); + self.tab_to_close = index; + } } else { - self.close_tab_confirm.ask(); - self.tab_to_close = index; + egui::Context::send_viewport_cmd(ctx, egui::ViewportCommand::Close); } } ui.separator();