mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-04 10:12:47 +00:00
Do not start searching if query is empty (#9333)
This avoids the problem of a search being kicked off involuntarily and potentially using a large amount of CPU when toggling on the `Search Ignored Files` option. What would happen is that someone would turn the option on, we'd kick off a search, and go through all of the files in, say, `node_modules`. Even if no query was given. This avoids that. Release Notes: - Fixed an empty search being kicked off involuntarily if no query was typed in yet but an option was toggled.
This commit is contained in:
parent
f142568172
commit
c015baa638
2 changed files with 7 additions and 0 deletions
|
@ -327,6 +327,10 @@ impl SearchQuery {
|
|||
matches
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.as_str().is_empty()
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.as_inner().as_str()
|
||||
}
|
||||
|
|
|
@ -1231,6 +1231,9 @@ impl ProjectSearchView {
|
|||
if !self.panels_with_errors.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if query.as_ref().is_some_and(|query| query.is_empty()) {
|
||||
return None;
|
||||
}
|
||||
query
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue