Add searchable global tab switcher (#28047)

resolves #24655
resolves #23945

I haven't yet added a default binding for the new command. #27797 added `:ls` and
`:buffers` which in my opinion should use the global searchable version
given that that matches the vim semantics of those commands better than
just showing the tabs in the local pane.

There's also a question of what to do when you select a tab from another
pane, should the focus jump to that pane or should that tab move to the
currently focused pane? For now I've implemented the former.

Release Notes:

- Added `tab_switcher::ToggleAll` to search open tabs from all panes and focus the selected one.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Julia Ryan 2025-04-28 02:21:27 -07:00 committed by GitHub
parent 52eef3c35d
commit 4dff47ae20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 360 additions and 181 deletions

View file

@ -1460,6 +1460,27 @@ impl Workspace {
&self.project
}
pub fn recently_activated_items(&self, cx: &App) -> HashMap<EntityId, usize> {
let mut history: HashMap<EntityId, usize> = HashMap::default();
for pane_handle in &self.panes {
let pane = pane_handle.read(cx);
for entry in pane.activation_history() {
history.insert(
entry.entity_id,
history
.get(&entry.entity_id)
.cloned()
.unwrap_or(0)
.max(entry.timestamp),
);
}
}
history
}
pub fn recent_navigation_history_iter(
&self,
cx: &App,
@ -2105,7 +2126,7 @@ impl Workspace {
.flat_map(|pane| {
pane.read(cx).items().filter_map(|item| {
if item.is_dirty(cx) {
item.tab_description(0, cx);
item.tab_content_text(0, cx);
Some((pane.downgrade(), item.boxed_clone()))
} else {
None
@ -9022,6 +9043,9 @@ mod tests {
impl Item for TestPngItemView {
type Event = ();
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
"".into()
}
}
impl EventEmitter<()> for TestPngItemView {}
impl Focusable for TestPngItemView {
@ -9094,6 +9118,9 @@ mod tests {
impl Item for TestIpynbItemView {
type Event = ();
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
"".into()
}
}
impl EventEmitter<()> for TestIpynbItemView {}
impl Focusable for TestIpynbItemView {
@ -9137,6 +9164,9 @@ mod tests {
impl Item for TestAlternatePngItemView {
type Event = ();
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
"".into()
}
}
impl EventEmitter<()> for TestAlternatePngItemView {}