Add sleeping tab recovery
This commit is contained in:
@@ -277,11 +277,20 @@ impl BrowserCore {
|
||||
self.crash_active_tab()?;
|
||||
Ok(true)
|
||||
}
|
||||
"sleep-tab" | "sleep tab" | "discard-tab" | "discard tab" => {
|
||||
self.discard_active_tab()?;
|
||||
Ok(true)
|
||||
}
|
||||
"recover-tab" | "recover tab" | "recover-crashed-tab" | "recover crashed tab" => {
|
||||
let tab_id = self.active_tab()?.id().clone();
|
||||
self.recover_crashed_tab(&tab_id)?;
|
||||
Ok(true)
|
||||
}
|
||||
"wake-tab" | "wake tab" | "restore-sleeping-tab" | "restore sleeping tab" => {
|
||||
let tab_id = self.active_tab()?.id().clone();
|
||||
self.wake_discarded_tab(&tab_id)?;
|
||||
Ok(true)
|
||||
}
|
||||
"close-split-view" | "close split view" => {
|
||||
Ok(self.close_active_saved_split_view()?.is_some())
|
||||
}
|
||||
|
||||
+23
@@ -20,6 +20,29 @@ impl BrowserCore {
|
||||
}
|
||||
|
||||
pub fn recover_crashed_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
self.mark_tab_ready(tab_id)
|
||||
}
|
||||
|
||||
pub fn discard_active_tab(&mut self) -> Result<TabId, CoreError> {
|
||||
let tab_id = self.active_tab_id.clone();
|
||||
self.discard_tab(&tab_id)
|
||||
}
|
||||
|
||||
pub fn discard_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
let tab = self
|
||||
.tabs
|
||||
.iter_mut()
|
||||
.find(|tab| tab.id() == tab_id)
|
||||
.ok_or_else(|| CoreError::TabNotFound { id: tab_id.clone() })?;
|
||||
tab.mark_discarded();
|
||||
Ok(tab_id.clone())
|
||||
}
|
||||
|
||||
pub fn wake_discarded_tab(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
self.mark_tab_ready(tab_id)
|
||||
}
|
||||
|
||||
fn mark_tab_ready(&mut self, tab_id: &TabId) -> Result<TabId, CoreError> {
|
||||
{
|
||||
let tab = self
|
||||
.tabs
|
||||
Reference in New Issue
Block a user