tab_switcher: Add tab close buttons (#9968)

Support for closing tabs from Tab Switcher:

- Close button color matches the indicator color to preserve the
information that the buffer is dirty (as in SublimeText).
- `ctrl-backspace` closes the currently selected item.


https://github.com/zed-industries/zed/assets/2101250/8ea33911-2f62-4199-826d-c17556db8e9a

Release Notes:

- N/A
This commit is contained in:
Andrew Lygin 2024-04-03 18:28:51 +03:00 committed by GitHub
parent 8eeecdafec
commit 57a1b9b2cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 156 additions and 13 deletions

View file

@ -61,6 +61,9 @@ pub trait PickerDelegate: Sized + 'static {
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>);
fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc<str>;
fn no_matches_text(&self, _cx: &mut WindowContext) -> SharedString {
"No matches".into()
}
fn update_matches(&mut self, query: String, cx: &mut ViewContext<Picker<Self>>) -> Task<()>;
// Delegates that support this method (e.g. the CommandPalette) can chose to block on any background
@ -524,7 +527,9 @@ impl<D: PickerDelegate> Render for Picker<D> {
.inset(true)
.spacing(ListItemSpacing::Sparse)
.disabled(true)
.child(Label::new("No matches").color(Color::Muted)),
.child(
Label::new(self.delegate.no_matches_text(cx)).color(Color::Muted),
),
),
)
})