Fix ssh project history (#19683)
Use `Fs` instead of `std::fs` and do entry existence checks better: * first, check the worktree entry existence without any FS checks * then, only for local cases, use `Fs` to check for abs_path existence of items, in case those came from single-filed worktrees that got closed and removed. Remote entries do not get file existence checks, so might try opening previously removed buffers for now. Release Notes: - N/A
This commit is contained in:
parent
3ec015b325
commit
454d3dd52b
5 changed files with 80 additions and 52 deletions
|
@ -1875,11 +1875,7 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_open_buffer(
|
||||
&mut self,
|
||||
path: &ProjectPath,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Option<Model<Buffer>> {
|
||||
pub fn get_open_buffer(&self, path: &ProjectPath, cx: &AppContext) -> Option<Model<Buffer>> {
|
||||
self.buffer_store.read(cx).get_by_path(path, cx)
|
||||
}
|
||||
|
||||
|
@ -3295,17 +3291,10 @@ impl Project {
|
|||
}
|
||||
|
||||
pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option<PathBuf> {
|
||||
let workspace_root = self
|
||||
.worktree_for_id(project_path.worktree_id, cx)?
|
||||
self.worktree_for_id(project_path.worktree_id, cx)?
|
||||
.read(cx)
|
||||
.abs_path();
|
||||
let project_path = project_path.path.as_ref();
|
||||
|
||||
Some(if project_path == Path::new("") {
|
||||
workspace_root.to_path_buf()
|
||||
} else {
|
||||
workspace_root.join(project_path)
|
||||
})
|
||||
.absolutize(&project_path.path)
|
||||
.ok()
|
||||
}
|
||||
|
||||
/// Attempts to find a `ProjectPath` corresponding to the given path. If the path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue