zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.05k stars 2.84k forks source link

Image preview does not detect file changes and update #11529

Open markusmoenig opened 5 months ago

markusmoenig commented 5 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

The PNG image preview inside Zed does not update when the image changes.

Environment

Zed: v0.133.7 (Zed) OS: macOS 14.4.1 Memory: 24 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

bbb651 commented 4 months ago

I want to take a stab in implementing it and I'm not sure where/if it should go within the Asset system. It's used for both images and commit avatars, and images can be used with files, uris or data (not relevant since it skips the asset system all together), and out of all of them only images based on files make sense to watch, so it needs to be optional, watching outside the asset system and calling remove_cached_asset than use_cached_asset seems like a bad idea, and skipping the asset system means losing out/duplicating caching. Also I'm a bit confused as to why crates/gpui/src/elements/img.rs:371 does a blocking read for files when the entire system is build to be async, is there a reason for that?

jackTabsCode commented 3 months ago

Just ran into this-really surprised this isn't fixed yet and I lost a lot of time today thinking Figma was broken...

markusmoenig commented 3 months ago

I also can't understand why this is not fixed. For those of use working with images it is a deal breaker. Only explanation I have is that they want to move all this into extensions but the extension engine is not yet far enough along to support it.

phultquist commented 3 months ago

Here's an easy repro of it / video for a maintainer:

from PIL import Image
import random

# save an image from a random color to ./img.png

r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
img = Image.new('RGB', (512, 512), color = (r, g, b))

img.save('./img.png')

https://github.com/zed-industries/zed/assets/46694203/841912d1-f6b4-4087-9718-9841b9e3688e

notpeter commented 1 month ago

This is still broken in Zed Nightly 0.151.0.

Steps to reproduce:

  1. Download mario.png and luigi.png mario luigi
  2. Open mario.png in Zed.
  3. From the command line cp luigi.png mario.png

Notice Zed still shows the Mario and not the Luigi! Zed should listen for image changes with inotify just like we do for other file buffers.

Supremesource commented 2 weeks ago

Shame such core thing is not fixed yet. I spent 5 hours of debugging just to find out there is something like this