Z-1074/search default label (#2547)

This commit adds a default "Project search" tooltip for empty search
panes. Fixes Linear ticket Z-1074
Release Notes:

- Added default tooltip to empty search panes.
([#1533](https://github.com/zed-industries/community/issues/1533)).
This commit is contained in:
Piotr Osiewicz 2023-06-02 11:42:40 +02:00 committed by GitHub
commit 571d2f4966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,7 +25,7 @@ use std::{
borrow::Cow,
collections::HashSet,
mem,
ops::Range,
ops::{Not, Range},
path::PathBuf,
sync::Arc,
};
@ -242,7 +242,13 @@ impl View for ProjectSearchView {
impl Item for ProjectSearchView {
fn tab_tooltip_text(&self, cx: &AppContext) -> Option<Cow<str>> {
Some(self.query_editor.read(cx).text(cx).into())
let query_text = self.query_editor.read(cx).text(cx);
query_text
.is_empty()
.not()
.then(|| query_text.into())
.or_else(|| Some("Project Search".into()))
}
fn act_as_type<'a>(