Archive closed browser tabs

This commit is contained in:
2026-05-07 19:53:32 -04:00
parent 82df2b4502
commit e0eb5b51b2
9 changed files with 150 additions and 5 deletions
+5
View File
@@ -14,6 +14,7 @@ actions!(
FocusAddressBar,
OpenNewTab,
Quit,
RestoreClosedTab,
SelectNextTab,
SelectPreviousTab,
ToggleFavoriteTab,
@@ -32,6 +33,8 @@ fn main() {
KeyBinding::new("ctrl-l", FocusAddressBar, None),
KeyBinding::new("cmd-w", CloseCurrentTab, None),
KeyBinding::new("ctrl-w", CloseCurrentTab, None),
KeyBinding::new("cmd-shift-t", RestoreClosedTab, None),
KeyBinding::new("ctrl-shift-t", RestoreClosedTab, None),
KeyBinding::new("cmd-shift-f", ToggleFavoriteTab, None),
KeyBinding::new("ctrl-shift-f", ToggleFavoriteTab, None),
KeyBinding::new("cmd-shift-p", TogglePinnedTab, None),
@@ -58,6 +61,8 @@ fn main() {
MenuItem::separator(),
MenuItem::action("Close Tab", CloseCurrentTab),
MenuItem::separator(),
MenuItem::action("Restore Closed Tab", RestoreClosedTab),
MenuItem::separator(),
MenuItem::action("Toggle Pin", TogglePinnedTab),
],
},
+20 -2
View File
@@ -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,
+1
View File
@@ -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))