Do not render recent paths in toolbar's project switcher

This commit is contained in:
Piotr Osiewicz 2023-07-05 18:04:40 +02:00
parent ec47464bba
commit 0e0d78df84

View file

@ -48,7 +48,7 @@ fn toggle(
let workspace = cx.weak_handle(); let workspace = cx.weak_handle();
cx.add_view(|cx| { cx.add_view(|cx| {
RecentProjects::new( RecentProjects::new(
RecentProjectsDelegate::new(workspace, workspace_locations), RecentProjectsDelegate::new(workspace, workspace_locations, true),
cx, cx,
) )
.with_max_size(800., 1200.) .with_max_size(800., 1200.)
@ -69,8 +69,11 @@ pub fn build_recent_projects(
workspaces: Vec<WorkspaceLocation>, workspaces: Vec<WorkspaceLocation>,
cx: &mut ViewContext<RecentProjects>, cx: &mut ViewContext<RecentProjects>,
) -> RecentProjects { ) -> RecentProjects {
Picker::new(RecentProjectsDelegate::new(workspace, workspaces), cx) Picker::new(
.with_theme(|theme| theme.picker.clone()) RecentProjectsDelegate::new(workspace, workspaces, false),
cx,
)
.with_theme(|theme| theme.picker.clone())
} }
pub type RecentProjects = Picker<RecentProjectsDelegate>; pub type RecentProjects = Picker<RecentProjectsDelegate>;
@ -80,18 +83,21 @@ pub struct RecentProjectsDelegate {
workspace_locations: Vec<WorkspaceLocation>, workspace_locations: Vec<WorkspaceLocation>,
selected_match_index: usize, selected_match_index: usize,
matches: Vec<StringMatch>, matches: Vec<StringMatch>,
render_paths: bool,
} }
impl RecentProjectsDelegate { impl RecentProjectsDelegate {
fn new( fn new(
workspace: WeakViewHandle<Workspace>, workspace: WeakViewHandle<Workspace>,
workspace_locations: Vec<WorkspaceLocation>, workspace_locations: Vec<WorkspaceLocation>,
render_paths: bool,
) -> Self { ) -> Self {
Self { Self {
workspace, workspace,
workspace_locations, workspace_locations,
selected_match_index: 0, selected_match_index: 0,
matches: Default::default(), matches: Default::default(),
render_paths,
} }
} }
} }
@ -197,6 +203,7 @@ impl PickerDelegate for RecentProjectsDelegate {
highlighted_location highlighted_location
.paths .paths
.into_iter() .into_iter()
.filter(|_| self.render_paths)
.map(|highlighted_path| highlighted_path.render(style.label.clone())), .map(|highlighted_path| highlighted_path.render(style.label.clone())),
) )
.flex(1., false) .flex(1., false)