Make project search feel better (#14674)

Release Notes:

- Improved UX of project search

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Conrad Irwin 2024-07-17 14:14:46 -06:00 committed by GitHub
parent 84b34677e2
commit 09b216cf5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 123 additions and 64 deletions

View file

@ -52,10 +52,10 @@ bitflags! {
impl SearchOptions {
pub fn label(&self) -> &'static str {
match *self {
SearchOptions::WHOLE_WORD => "whole word",
SearchOptions::CASE_SENSITIVE => "match case",
SearchOptions::INCLUDE_IGNORED => "include Ignored",
SearchOptions::REGEX => "regular expression",
SearchOptions::WHOLE_WORD => "Match whole words",
SearchOptions::CASE_SENSITIVE => "Match case sensitively",
SearchOptions::INCLUDE_IGNORED => "Also search files ignored by configuration",
SearchOptions::REGEX => "Use regular expressions",
_ => panic!("{:?} is not a named SearchOption", self),
}
}
@ -64,7 +64,7 @@ impl SearchOptions {
match *self {
SearchOptions::WHOLE_WORD => ui::IconName::WholeWord,
SearchOptions::CASE_SENSITIVE => ui::IconName::CaseSensitive,
SearchOptions::INCLUDE_IGNORED => ui::IconName::FileGit,
SearchOptions::INCLUDE_IGNORED => ui::IconName::Sliders,
SearchOptions::REGEX => ui::IconName::Regex,
_ => panic!("{:?} is not a named SearchOption", self),
}
@ -104,8 +104,8 @@ impl SearchOptions {
.selected(active)
.tooltip({
let action = self.to_toggle_action();
let label: SharedString = format!("Toggle {}", self.label()).into();
move |cx| Tooltip::for_action(label.clone(), &*action, cx)
let label = self.label();
move |cx| Tooltip::for_action(label, &*action, cx)
})
}
}