Allow removing workspaces from the "recent projects" modal (#7885)

<img width="492" alt="Screenshot 2024-02-19 at 10 59 01 AM"
src="https://github.com/zed-industries/zed/assets/1823955/922117f6-81c1-409d-938a-131bcec0f24c">

<img width="675" alt="Screenshot 2024-02-19 at 10 59 27 AM"
src="https://github.com/zed-industries/zed/assets/1823955/fefac68b-9a99-43bb-ac0c-724e7c622455">

Release Notes:

- Added a way to remove entries from the recent projects modal
([7426](https://github.com/zed-industries/zed/issues/7426)).
This commit is contained in:
Tung Hoang 2024-02-21 15:30:02 -08:00 committed by GitHub
parent 266bb62813
commit f930969411
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 98 additions and 40 deletions

View file

@ -1,7 +1,7 @@
use editor::Editor;
use gpui::{
div, list, prelude::*, uniform_list, AnyElement, AppContext, DismissEvent, EventEmitter,
FocusHandle, FocusableView, Length, ListState, MouseButton, MouseDownEvent, Render, Task,
div, list, prelude::*, uniform_list, AnyElement, AppContext, ClickEvent, DismissEvent,
EventEmitter, FocusHandle, FocusableView, Length, ListState, Render, Task,
UniformListScrollHandle, View, ViewContext, WindowContext,
};
use std::{sync::Arc, time::Duration};
@ -103,7 +103,7 @@ impl<D: PickerDelegate> Picker<D> {
let mut this = Self {
delegate,
editor,
element_container: Self::crate_element_container(is_uniform, cx),
element_container: Self::create_element_container(is_uniform, cx),
pending_update_matches: None,
confirm_on_update: None,
width: None,
@ -117,7 +117,7 @@ impl<D: PickerDelegate> Picker<D> {
this
}
fn crate_element_container(is_uniform: bool, cx: &mut ViewContext<Self>) -> ElementContainer {
fn create_element_container(is_uniform: bool, cx: &mut ViewContext<Self>) -> ElementContainer {
if is_uniform {
ElementContainer::UniformList(UniformListScrollHandle::new())
} else {
@ -311,12 +311,10 @@ impl<D: PickerDelegate> Picker<D> {
fn render_element(&self, cx: &mut ViewContext<Self>, ix: usize) -> impl IntoElement {
div()
.on_mouse_down(
MouseButton::Left,
cx.listener(move |this, event: &MouseDownEvent, cx| {
this.handle_click(ix, event.modifiers.command, cx)
}),
)
.id(("item", ix))
.on_click(cx.listener(move |this, event: &ClickEvent, cx| {
this.handle_click(ix, event.down.modifiers.command, cx)
}))
.children(
self.delegate
.render_match(ix, ix == self.delegate.selected_index(), cx),