Merge branch 'main' into optimize-large-multi-buffers

This commit is contained in:
Antonio Scandurra 2023-01-19 16:18:21 +01:00
commit a58b39f884
19 changed files with 312 additions and 243 deletions

View file

@ -67,8 +67,9 @@ use util::{debug_panic, defer, post_inc, ResultExt, TryFutureExt as _};
pub use fs::*;
pub use worktree::*;
pub trait Item: Entity {
pub trait Item {
fn entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId>;
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
}
// Language server state is stored across 3 collections:
@ -6405,4 +6406,11 @@ impl Item for Buffer {
fn entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId> {
File::from_dyn(self.file()).and_then(|file| file.project_entry_id(cx))
}
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath> {
File::from_dyn(self.file()).map(|file| ProjectPath {
worktree_id: file.worktree_id(cx),
path: file.path().clone(),
})
}
}