tab_switcher: Add support for tab switcher in assistant panel (#15475)

Additionally, I've generalized the implementation of tab switcher so
that - instead of explicitly listing panels it supports (at the time of
writing it was just the terminal panel and nothing else), it now relies
on Panel::pane trait method. As long as that's implemented, you get a
tab switcher support for free.

Release Notes:

- Added support for tab switcher in Assistant panel.
This commit is contained in:
Piotr Osiewicz 2024-07-30 13:32:13 +02:00 committed by GitHub
parent 0540291204
commit 530feecdaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 32 deletions

View file

@ -9,7 +9,7 @@ use gpui::{AppContext, Task, WeakView};
use language::{CodeLabel, LspAdapterDelegate};
use terminal_view::{terminal_panel::TerminalPanel, TerminalView};
use ui::prelude::*;
use workspace::Workspace;
use workspace::{dock::Panel, Workspace};
use super::create_label_for_command;
@ -65,13 +65,11 @@ impl SlashCommand for TermSlashCommand {
let Some(terminal_panel) = workspace.read(cx).panel::<TerminalPanel>(cx) else {
return Task::ready(Err(anyhow::anyhow!("no terminal panel open")));
};
let Some(active_terminal) = terminal_panel
.read(cx)
.pane()
.read(cx)
.active_item()
.and_then(|t| t.downcast::<TerminalView>())
else {
let Some(active_terminal) = terminal_panel.read(cx).pane().and_then(|pane| {
pane.read(cx)
.active_item()
.and_then(|t| t.downcast::<TerminalView>())
}) else {
return Task::ready(Err(anyhow::anyhow!("no active terminal")));
};