Fix search sorting (#16970)

Ensures we sort paths in search the same as we do in panels.

Ideally we'd store things like this in the worktree, but the sort order
depends
on file vs directory, and callers generally don't know which they're
asking for.

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-08-27 13:46:36 -06:00 committed by GitHub
parent 442ff94d58
commit 8643b11f57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 152 additions and 70 deletions

View file

@ -425,23 +425,18 @@ impl SearchQuery {
&& self.files_to_include().sources().is_empty())
}
pub fn file_matches(&self, file_path: Option<&Path>) -> bool {
match file_path {
Some(file_path) => {
let mut path = file_path.to_path_buf();
loop {
if self.files_to_exclude().is_match(&path) {
return false;
} else if self.files_to_include().sources().is_empty()
|| self.files_to_include().is_match(&path)
{
return true;
} else if !path.pop() {
return false;
}
}
pub fn file_matches(&self, file_path: &Path) -> bool {
let mut path = file_path.to_path_buf();
loop {
if self.files_to_exclude().is_match(&path) {
return false;
} else if self.files_to_include().sources().is_empty()
|| self.files_to_include().is_match(&path)
{
return true;
} else if !path.pop() {
return false;
}
None => self.files_to_include().sources().is_empty(),
}
}
pub fn as_inner(&self) -> &SearchInputs {