Merge branch 'main' into stream-git-statuses

This commit is contained in:
Mikayla Maki 2023-06-07 14:12:58 -07:00
commit 28ba27c9c5
No known key found for this signature in database
206 changed files with 5946 additions and 3086 deletions

View file

@ -571,6 +571,11 @@ impl Worktree {
Worktree::Remote(worktree) => worktree.abs_path.clone(),
}
}
pub fn root_file(&self, cx: &mut ModelContext<Self>) -> Option<Arc<File>> {
let entry = self.root_entry()?;
Some(File::for_entry(entry.clone(), cx.handle()))
}
}
impl LocalWorktree {
@ -578,14 +583,6 @@ impl LocalWorktree {
path.starts_with(&self.abs_path)
}
fn absolutize(&self, path: &Path) -> PathBuf {
if path.file_name().is_some() {
self.abs_path.join(path)
} else {
self.abs_path.to_path_buf()
}
}
pub(crate) fn load_buffer(
&mut self,
id: u64,
@ -1429,6 +1426,14 @@ impl Snapshot {
&self.abs_path
}
pub fn absolutize(&self, path: &Path) -> PathBuf {
if path.file_name().is_some() {
self.abs_path.join(path)
} else {
self.abs_path.to_path_buf()
}
}
pub fn contains_entry(&self, entry_id: ProjectEntryId) -> bool {
self.entries_by_id.get(&entry_id, &()).is_some()
}
@ -2360,6 +2365,10 @@ impl language::File for File {
.unwrap_or_else(|| OsStr::new(&self.worktree.read(cx).root_name))
}
fn worktree_id(&self) -> usize {
self.worktree.id()
}
fn is_deleted(&self) -> bool {
self.is_deleted
}
@ -2424,6 +2433,17 @@ impl language::LocalFile for File {
}
impl File {
pub fn for_entry(entry: Entry, worktree: ModelHandle<Worktree>) -> Arc<Self> {
Arc::new(Self {
worktree,
path: entry.path.clone(),
mtime: entry.mtime,
entry_id: entry.id,
is_local: true,
is_deleted: false,
})
}
pub fn from_proto(
proto: rpc::proto::File,
worktree: ModelHandle<Worktree>,
@ -2485,7 +2505,7 @@ pub enum EntryKind {
File(CharBag),
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PathChange {
/// A filesystem entry was was created.
Added,
@ -3617,7 +3637,7 @@ pub trait WorktreeHandle {
impl WorktreeHandle for ModelHandle<Worktree> {
// When the worktree's FS event stream sometimes delivers "redundant" events for FS changes that
// occurred before the worktree was constructed. These events can cause the worktree to perfrom
// occurred before the worktree was constructed. These events can cause the worktree to perform
// extra directory scans, and emit extra scan-state notifications.
//
// This function mutates the worktree's directory and waits for those mutations to be picked up,