Merge branch 'main' into theme-variables
This commit is contained in:
+20
-24
@@ -48,7 +48,7 @@ pub struct PathMatch {
|
||||
pub positions: Vec<usize>,
|
||||
pub tree_id: usize,
|
||||
pub path: Arc<Path>,
|
||||
pub include_root_name: bool,
|
||||
pub path_prefix: Arc<str>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -207,23 +207,19 @@ pub async fn match_strings(
|
||||
results
|
||||
}
|
||||
|
||||
pub async fn match_paths<'a, T>(
|
||||
snapshots: T,
|
||||
pub async fn match_paths(
|
||||
snapshots: &[Snapshot],
|
||||
query: &str,
|
||||
include_root_name: bool,
|
||||
include_ignored: bool,
|
||||
smart_case: bool,
|
||||
max_results: usize,
|
||||
cancel_flag: &AtomicBool,
|
||||
background: Arc<executor::Background>,
|
||||
) -> Vec<PathMatch>
|
||||
where
|
||||
T: Clone + Send + Iterator<Item = &'a Snapshot> + 'a,
|
||||
{
|
||||
) -> Vec<PathMatch> {
|
||||
let path_count: usize = if include_ignored {
|
||||
snapshots.clone().map(Snapshot::file_count).sum()
|
||||
snapshots.iter().map(Snapshot::file_count).sum()
|
||||
} else {
|
||||
snapshots.clone().map(Snapshot::visible_file_count).sum()
|
||||
snapshots.iter().map(Snapshot::visible_file_count).sum()
|
||||
};
|
||||
if path_count == 0 {
|
||||
return Vec::new();
|
||||
@@ -245,7 +241,6 @@ where
|
||||
background
|
||||
.scoped(|scope| {
|
||||
for (segment_idx, results) in segment_results.iter_mut().enumerate() {
|
||||
let snapshots = snapshots.clone();
|
||||
scope.spawn(async move {
|
||||
let segment_start = segment_idx * segment_size;
|
||||
let segment_end = segment_start + segment_size;
|
||||
@@ -265,9 +260,16 @@ where
|
||||
tree_start + snapshot.visible_file_count()
|
||||
};
|
||||
|
||||
let include_root_name =
|
||||
include_root_name || snapshot.root_entry().is_file();
|
||||
if tree_start < segment_end && segment_start < tree_end {
|
||||
let path_prefix: Arc<str> =
|
||||
if snapshot.root_entry().map_or(false, |e| e.is_file()) {
|
||||
snapshot.root_name().into()
|
||||
} else if snapshots.len() > 1 {
|
||||
format!("{}/", snapshot.root_name()).into()
|
||||
} else {
|
||||
"".into()
|
||||
};
|
||||
|
||||
let start = max(tree_start, segment_start) - tree_start;
|
||||
let end = min(tree_end, segment_end) - tree_start;
|
||||
let entries = if include_ignored {
|
||||
@@ -288,7 +290,7 @@ where
|
||||
|
||||
matcher.match_paths(
|
||||
snapshot,
|
||||
include_root_name,
|
||||
path_prefix,
|
||||
paths,
|
||||
results,
|
||||
&cancel_flag,
|
||||
@@ -360,19 +362,13 @@ impl<'a> Matcher<'a> {
|
||||
fn match_paths(
|
||||
&mut self,
|
||||
snapshot: &Snapshot,
|
||||
include_root_name: bool,
|
||||
path_prefix: Arc<str>,
|
||||
path_entries: impl Iterator<Item = PathMatchCandidate<'a>>,
|
||||
results: &mut Vec<PathMatch>,
|
||||
cancel_flag: &AtomicBool,
|
||||
) {
|
||||
let tree_id = snapshot.id;
|
||||
let prefix = if include_root_name {
|
||||
snapshot.root_name()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
.chars()
|
||||
.collect::<Vec<_>>();
|
||||
let prefix = path_prefix.chars().collect::<Vec<_>>();
|
||||
let lowercase_prefix = prefix
|
||||
.iter()
|
||||
.map(|c| c.to_ascii_lowercase())
|
||||
@@ -388,7 +384,7 @@ impl<'a> Matcher<'a> {
|
||||
tree_id,
|
||||
positions: Vec::new(),
|
||||
path: candidate.path.clone(),
|
||||
include_root_name,
|
||||
path_prefix: path_prefix.clone(),
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -772,7 +768,7 @@ mod tests {
|
||||
root_char_bag: Default::default(),
|
||||
next_entry_id: Default::default(),
|
||||
},
|
||||
false,
|
||||
"".into(),
|
||||
path_entries.into_iter(),
|
||||
&mut results,
|
||||
&cancel_flag,
|
||||
|
||||
Reference in New Issue
Block a user