Archive closed browser tabs
This commit is contained in:
@@ -6,8 +6,8 @@ use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscriptio
|
||||
use gpui_component::input::{InputEvent, InputState, SelectAll};
|
||||
|
||||
use crate::{
|
||||
CloseCurrentTab, FocusAddressBar, OpenNewTab, SelectNextTab, SelectPreviousTab,
|
||||
ToggleFavoriteTab, TogglePinnedTab,
|
||||
CloseCurrentTab, FocusAddressBar, OpenNewTab, RestoreClosedTab, SelectNextTab,
|
||||
SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
|
||||
};
|
||||
|
||||
enum ShellState {
|
||||
@@ -133,6 +133,15 @@ impl ElyShell {
|
||||
}
|
||||
}
|
||||
|
||||
fn restore_closed_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& core.restore_last_archived_tab().is_ok()
|
||||
{
|
||||
self.sync_address_input(window, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_active_tab_favorite(&mut self, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& core.toggle_active_tab_favorite().is_ok()
|
||||
@@ -171,6 +180,15 @@ impl ElyShell {
|
||||
self.open_new_tab(window, cx);
|
||||
}
|
||||
|
||||
fn on_restore_closed_tab(
|
||||
&mut self,
|
||||
_: &RestoreClosedTab,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.restore_closed_tab(window, cx);
|
||||
}
|
||||
|
||||
fn on_select_next_tab(
|
||||
&mut self,
|
||||
_: &SelectNextTab,
|
||||
|
||||
@@ -38,6 +38,7 @@ impl ElyShell {
|
||||
.on_action(cx.listener(Self::on_close_current_tab))
|
||||
.on_action(cx.listener(Self::on_focus_address_bar))
|
||||
.on_action(cx.listener(Self::on_open_new_tab))
|
||||
.on_action(cx.listener(Self::on_restore_closed_tab))
|
||||
.on_action(cx.listener(Self::on_select_next_tab))
|
||||
.on_action(cx.listener(Self::on_select_previous_tab))
|
||||
.on_action(cx.listener(Self::on_toggle_favorite_tab))
|
||||
|
||||
Reference in New Issue
Block a user