Commit 4b2382bf93
Unregistered key
Layout: unified · split
src/message/mod.rs +14 −3
| @@ -172,7 +172,8 @@ fn placeholder_frame( | ||
| 172 | 172 | image_preview_size: &ImagePreviewSize, |
| 173 | 173 | ) -> Option<String> { |
| 174 | 174 | let ImagePreviewSize { width, height } = image_preview_size; |
| 175 | if outer_width < *width || (*width < 2 || *height < 2) { | |
| 175 | let width = usize::min(*width, outer_width); | |
| 176 | if width < 2 || *height < 2 { | |
| 176 | 177 | return None; |
| 177 | 178 | } |
| 178 | 179 | let mut placeholder = "\u{230c}".to_string(); |
| @@ -1083,7 +1084,7 @@ impl Message { | ||
| 1083 | 1084 | }, |
| 1084 | 1085 | ImageStatus::Loaded(backend) => { |
| 1085 | 1086 | proto = Some(backend); |
| 1086 | placeholder_frame(Some("Cut off..."), width, &backend.area().into()) | |
| 1087 | placeholder_frame(Some("No Space..."), width, &backend.area().into()) | |
| 1087 | 1088 | }, |
| 1088 | 1089 | ImageStatus::Error(err) => Some(format!("[Image error: {err}]\n")), |
| 1089 | 1090 | }; |
| @@ -1341,7 +1342,17 @@ pub mod tests { | ||
| 1341 | 1342 | ) |
| 1342 | 1343 | ); |
| 1343 | 1344 | |
| 1344 | assert_eq!(placeholder_frame(None, 2, &ImagePreviewSize { width: 4, height: 4 }), None); | |
| 1345 | assert_eq!( | |
| 1346 | placeholder_frame(None, 2, &ImagePreviewSize { width: 4, height: 4 }), | |
| 1347 | pretty_frame_test( | |
| 1348 | r#" | |
| 1349 | ⌌⌍ | |
| 1350 | ||
| 1351 | ||
| 1352 | ⌎⌏ | |
| 1353 | "# | |
| 1354 | ) | |
| 1355 | ); | |
| 1345 | 1356 | assert_eq!(placeholder_frame(None, 4, &ImagePreviewSize { width: 1, height: 4 }), None); |
| 1346 | 1357 | |
| 1347 | 1358 | assert_eq!(placeholder_frame(None, 4, &ImagePreviewSize { width: 4, height: 1 }), None); |