Skip to content

Fix fallback for non-image files - #63455

Closed
ThatKJ wants to merge 1 commit into
zed-industries:mainfrom
ThatKJ:fix/image-extension-detection
Closed

Fix fallback for non-image files#63455
ThatKJ wants to merge 1 commit into
zed-industries:mainfrom
ThatKJ:fix/image-extension-detection

Conversation

@ThatKJ

@ThatKJ ThatKJ commented Aug 30, 2026

Copy link
Copy Markdown

Fixes #63449

The image viewer was picking files based on their extension before checking if the file was actually an image. Because of that, a normal text file like test.pam would end up showing the broken image view instead of opening in the editor.

This changes the opening flow so that if the image viewer checks the file and doesn't recognize it as an image, Workspace can try the next opener instead.

Valid images still open normally, and image decoding errors are still handled by the image viewer.

Added a regression test using a text test.pam file.

Tested with:

  • cargo test -p image_viewer --lib
  • cargo test -p workspace --lib register_project_item_tests
  • cargo fmt -- --check
  • ./script/clippy -p project -p workspace -p image_viewer

Release Notes:

  • Fixed non-image files with image extensions opening in the image viewer instead of the editor.

@cla-bot

cla-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @ThatKJ on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Aug 30, 2026
@ThatKJ

ThatKJ commented Aug 30, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot

cla-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @ThatKJ on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot

cla-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@ThatKJ

ThatKJ commented Aug 30, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 30, 2026
@cla-bot

cla-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@ChristopherBiscardi ChristopherBiscardi added the area:preview/images Feedback for image preview, zoom, manipulation, etc label Aug 31, 2026
@zed-industries-bot

Copy link
Copy Markdown
Contributor
Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against ecab3b3

@SomeoneToIgnore SomeoneToIgnore self-assigned this Aug 31, 2026
@SomeoneToIgnore

Copy link
Copy Markdown
Contributor

Thank you, this is a nice idea but the fix has to be a bit more generic, something similar to #63160 , and, ideally, avoid extra error handling in this way, as it's quite error-prone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preview/images Feedback for image preview, zoom, manipulation, etc cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed wrongly assumes file is an image based on extension

4 participants