Skip to content

Commit

Permalink
fix(tab): close window when close last tab
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen committed Dec 18, 2024
1 parent f15f136 commit 4947d46
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ impl TabManager {
}
/// Close a tab.
pub fn close_tab(&mut self, id: WebViewId) -> Result<WebView, TabManagerErr> {
// Skip if there's only one webview
if self.tab.len() == 1 {
return Err(TabManagerErr::RemoveLastWebView);
}

if let Some(idx) = self.tab_id_order.iter().position(|tab_id| *tab_id == id) {
self.tab_id_order.remove(idx);
}
Expand Down
3 changes: 2 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ impl Window {
}
(self.panel.take().map(|panel| panel.webview), false)
} else if let Ok(webview) = self.tab_manager.close_tab(id) {
(Some(webview), self.panel.is_none())
let close_window = self.tab_manager.count() == 0 || self.panel.is_none();
(Some(webview), close_window)
} else {
(None, false)
}
Expand Down

0 comments on commit 4947d46

Please sign in to comment.