From 39f202e1a68bb9c8f12ffeb298ec044836dca9ed Mon Sep 17 00:00:00 2001 From: anshul-garg27 Date: Wed, 29 Apr 2026 16:53:24 +0530 Subject: [PATCH] Recognize .bmp, .tiff, .tif, and .ico as supported image files --- app/src/util/openable_file_type.rs | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/app/src/util/openable_file_type.rs b/app/src/util/openable_file_type.rs index 1dce2c92..36d82f09 100644 --- a/app/src/util/openable_file_type.rs +++ b/app/src/util/openable_file_type.rs @@ -75,7 +75,7 @@ pub fn is_supported_image_file(path: impl AsRef) -> bool { .map(|ext| { matches!( ext.to_ascii_lowercase().as_str(), - "jpg" | "jpeg" | "png" | "gif" | "webp" | "svg" + "jpg" | "jpeg" | "png" | "gif" | "bmp" | "tiff" | "tif" | "webp" | "ico" | "svg" ) }) .unwrap_or(false) @@ -344,4 +344,36 @@ mod tests { assert!(!is_supported_code_file(Path::new("data.txt"))); assert!(!is_supported_code_file(Path::new("image.png"))); } + + /// `is_supported_image_file` should agree with the image extensions in + /// `warp_util::file_type::is_binary_file`, otherwise binary image files + /// like `.bmp` / `.tiff` / `.ico` get rejected by `is_file_openable_in_warp` + /// without ever being routed to `FileTarget::SystemGeneric`, leaving the + /// click-to-open path with no working target. + #[test] + fn test_is_supported_image_file_covers_common_formats() { + for name in [ + "photo.jpg", + "photo.jpeg", + "photo.png", + "icon.gif", + "screenshot.bmp", + "scan.tiff", + "scan.tif", + "asset.webp", + "favicon.ico", + "logo.svg", + ] { + assert!( + is_supported_image_file(Path::new(name)), + "{name} should be recognized as an image file" + ); + } + // Case-insensitive on the extension. + assert!(is_supported_image_file(Path::new("photo.PNG"))); + assert!(is_supported_image_file(Path::new("scan.TIFF"))); + // Sanity: non-image extensions are still rejected. + assert!(!is_supported_image_file(Path::new("readme.md"))); + assert!(!is_supported_image_file(Path::new("script.rs"))); + } }