Start work on respecting project-specific settings

This commit is contained in:
Max Brunsfeld 2023-05-29 13:48:27 -07:00
parent e4530471de
commit 89446c7fd4
16 changed files with 326 additions and 83 deletions

View file

@ -677,6 +677,18 @@ impl Worktree {
Worktree::Remote(worktree) => worktree.abs_path.clone(),
}
}
pub fn root_file(&self, cx: &mut ModelContext<Self>) -> Option<File> {
let entry = self.entry_for_path("")?;
Some(File {
worktree: cx.handle(),
path: entry.path.clone(),
mtime: entry.mtime,
entry_id: entry.id,
is_local: self.is_local(),
is_deleted: false,
})
}
}
impl LocalWorktree {
@ -684,14 +696,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,
@ -1544,6 +1548,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()
}
@ -2383,6 +2395,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
}
@ -2447,6 +2463,17 @@ impl language::LocalFile for File {
}
impl File {
pub fn for_entry(entry: Entry, worktree: ModelHandle<Worktree>) -> Self {
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>,
@ -2507,7 +2534,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,