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:
co-authored by
Conrad Irwin
parent
52eef3c35d
commit
4dff47ae20
@@ -19,7 +19,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use ui::{Color, Icon, IconName, Label, LabelCommon as _};
|
||||
use ui::{Color, Icon, IconName, Label, LabelCommon as _, SharedString};
|
||||
use util::{ResultExt, truncate_and_trailoff};
|
||||
use workspace::{
|
||||
Item, ItemHandle as _, ItemNavHistory, ToolbarItemLocation, Workspace,
|
||||
@@ -409,10 +409,8 @@ impl Item for CommitView {
|
||||
Some(Icon::new(IconName::GitBranch).color(Color::Muted))
|
||||
}
|
||||
|
||||
fn tab_content(&self, params: TabContentParams, _window: &Window, _: &App) -> AnyElement {
|
||||
let short_sha = self.commit.sha.get(0..7).unwrap_or(&*self.commit.sha);
|
||||
let subject = truncate_and_trailoff(self.commit.message.split('\n').next().unwrap(), 20);
|
||||
Label::new(format!("{short_sha} - {subject}",))
|
||||
fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement {
|
||||
Label::new(self.tab_content_text(params.detail.unwrap_or_default(), cx))
|
||||
.color(if params.selected {
|
||||
Color::Default
|
||||
} else {
|
||||
@@ -421,6 +419,12 @@ impl Item for CommitView {
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
|
||||
let short_sha = self.commit.sha.get(0..7).unwrap_or(&*self.commit.sha);
|
||||
let subject = truncate_and_trailoff(self.commit.message.split('\n').next().unwrap(), 20);
|
||||
format!("{short_sha} - {subject}").into()
|
||||
}
|
||||
|
||||
fn tab_tooltip_text(&self, _: &App) -> Option<ui::SharedString> {
|
||||
let short_sha = self.commit.sha.get(0..16).unwrap_or(&*self.commit.sha);
|
||||
let subject = self.commit.message.split('\n').next().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user