Restore the ability to drag and drop images into the editor (#31009)

`ImageItem`'s `file` is returning `""` as its `path` for single-filed
worktrees like the ones are created for the images dropped from the OS.
`ImageItem::load_image_metadata` had used that `path` in FS operations
and the other method tried to use for icon resolving.

Rework the code to use a more specific, `worktree::File` instead and
always use the `abs_path` when dealing with paths from this `file`.

Release Notes:

- Fixed images not opening on drag and drop into the editor
This commit is contained in:
Kirill Bulatov 2025-05-20 15:38:24 +03:00 committed by GitHub
parent 944a0df436
commit e4262f97af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 33 deletions

View file

@ -107,6 +107,15 @@ pub struct LoadedBinaryFile {
pub content: Vec<u8>,
}
impl fmt::Debug for LoadedBinaryFile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LoadedBinaryFile")
.field("file", &self.file)
.field("content_bytes", &self.content.len())
.finish()
}
}
pub struct LocalWorktree {
snapshot: LocalSnapshot,
scan_requests_tx: channel::Sender<ScanRequest>,
@ -3293,7 +3302,7 @@ impl fmt::Debug for Snapshot {
}
}
#[derive(Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub struct File {
pub worktree: Entity<Worktree>,
pub path: Arc<Path>,