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:
parent
442ff94d58
commit
8643b11f57
3 changed files with 152 additions and 70 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue