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:
parent
944a0df436
commit
e4262f97af
5 changed files with 39 additions and 33 deletions
|
@ -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>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue