@@ -75,7 +75,7 @@ pub fn is_supported_image_file(path: impl AsRef<Path>) -> bool {
7575 . map ( |ext| {
7676 matches ! (
7777 ext. to_ascii_lowercase( ) . as_str( ) ,
78- "jpg" | "jpeg" | "png" | "gif" | "webp" | "svg"
78+ "jpg" | "jpeg" | "png" | "gif" | "bmp" | "tiff" | "tif" | " webp" | "ico " | "svg"
7979 )
8080 } )
8181 . unwrap_or ( false )
@@ -344,4 +344,36 @@ mod tests {
344344 assert ! ( !is_supported_code_file( Path :: new( "data.txt" ) ) ) ;
345345 assert ! ( !is_supported_code_file( Path :: new( "image.png" ) ) ) ;
346346 }
347+
348+ /// `is_supported_image_file` should agree with the image extensions in
349+ /// `warp_util::file_type::is_binary_file`, otherwise binary image files
350+ /// like `.bmp` / `.tiff` / `.ico` get rejected by `is_file_openable_in_warp`
351+ /// without ever being routed to `FileTarget::SystemGeneric`, leaving the
352+ /// click-to-open path with no working target.
353+ #[ test]
354+ fn test_is_supported_image_file_covers_common_formats ( ) {
355+ for name in [
356+ "photo.jpg" ,
357+ "photo.jpeg" ,
358+ "photo.png" ,
359+ "icon.gif" ,
360+ "screenshot.bmp" ,
361+ "scan.tiff" ,
362+ "scan.tif" ,
363+ "asset.webp" ,
364+ "favicon.ico" ,
365+ "logo.svg" ,
366+ ] {
367+ assert ! (
368+ is_supported_image_file( Path :: new( name) ) ,
369+ "{name} should be recognized as an image file"
370+ ) ;
371+ }
372+ // Case-insensitive on the extension.
373+ assert ! ( is_supported_image_file( Path :: new( "photo.PNG" ) ) ) ;
374+ assert ! ( is_supported_image_file( Path :: new( "scan.TIFF" ) ) ) ;
375+ // Sanity: non-image extensions are still rejected.
376+ assert ! ( !is_supported_image_file( Path :: new( "readme.md" ) ) ) ;
377+ assert ! ( !is_supported_image_file( Path :: new( "script.rs" ) ) ) ;
378+ }
347379}
0 commit comments