Add desktop search and entry mutation workflows
This commit is contained in:
@@ -229,17 +229,23 @@ impl fmt::Debug for ShowResult {
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct NameMatch {
|
||||
path: String,
|
||||
kind: TreeNodeKind,
|
||||
id: TreeNodeId,
|
||||
}
|
||||
|
||||
impl NameMatch {
|
||||
pub fn path(&self) -> &str {
|
||||
&self.path
|
||||
self.id
|
||||
.path()
|
||||
.to_str()
|
||||
.expect("search construction rejects non-UTF-8 paths")
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> TreeNodeKind {
|
||||
self.kind
|
||||
self.id.kind()
|
||||
}
|
||||
|
||||
pub fn id(&self) -> &TreeNodeId {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +495,7 @@ impl<'a> VaultReader<'a> {
|
||||
let name = display_name(directory.path().as_path())?;
|
||||
if folded.iter().any(|term| name.to_lowercase().contains(term)) {
|
||||
matches.push(NameMatch {
|
||||
path: path_text(directory.path().as_path())?,
|
||||
kind: TreeNodeKind::Directory,
|
||||
id: TreeNodeId::Directory(directory.path().clone()),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -501,16 +506,12 @@ impl<'a> VaultReader<'a> {
|
||||
let name = display_name(entry.path().as_path())?;
|
||||
if folded.iter().any(|term| name.to_lowercase().contains(term)) {
|
||||
matches.push(NameMatch {
|
||||
path: path_text(entry.path().as_path())?,
|
||||
kind: TreeNodeKind::Entry,
|
||||
id: TreeNodeId::Entry(entry.path().clone()),
|
||||
});
|
||||
}
|
||||
}
|
||||
matches.sort_by(|left, right| left.path.cmp(&right.path));
|
||||
let included = matches
|
||||
.iter()
|
||||
.map(|matched| matched.path.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
matches.sort_by(|left, right| left.path().cmp(right.path()));
|
||||
let included = matches.iter().map(NameMatch::path).collect::<Vec<_>>();
|
||||
let tree = build_tree(&snapshot, &DirectoryPath::root(), Some(included.as_slice()))?;
|
||||
Ok(FindResults {
|
||||
terms: terms.to_vec(),
|
||||
|
||||
Reference in New Issue
Block a user