Made the map seek target a publicly implementable interface

Integrated remove_range with the existing git code

co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Mikayla Maki 2023-05-12 08:37:07 -07:00
parent ee3637216e
commit 6ef0f70528
No known key found for this signature in database
4 changed files with 48 additions and 37 deletions

View file

@ -3,12 +3,13 @@ use collections::HashMap;
use parking_lot::Mutex;
use serde_derive::{Deserialize, Serialize};
use std::{
cmp::Ordering,
ffi::OsStr,
os::unix::prelude::OsStrExt,
path::{Component, Path, PathBuf},
sync::Arc,
};
use sum_tree::TreeMap;
use sum_tree::{MapSeekTarget, TreeMap};
use util::ResultExt;
pub use git2::Repository as LibGitRepository;
@ -233,3 +234,16 @@ impl std::ops::Deref for RepoPath {
&self.0
}
}
#[derive(Debug)]
pub struct RepoPathDescendants<'a>(pub &'a Path);
impl<'a> MapSeekTarget<RepoPath> for RepoPathDescendants<'a> {
fn cmp_cursor(&self, key: &RepoPath) -> Ordering {
if key.starts_with(&self.0) {
Ordering::Greater
} else {
self.0.cmp(key)
}
}
}