images: improve logging when things are weird

refs: https://github.com/wez/wezterm/issues/3366
This commit is contained in:
Wez Furlong committed 2023-03-25 18:55:26 -07:00
1 parent d491c736ef
commit 727cd95dcd
2 files changed
+14 -2

No files matched your search

+5 -1
View File
@@ -110,7 +110,7 @@ impl TerminalState {
let first_row = self.screen().visible_row_to_stable_row(self.cursor.y);
let mut ypos = NotNan::new(params.source_origin_y as f32 / params.image_height as f32)
.context("computing ypos")?;
.with_context(|| format!("computing ypos {params:#?}"))?;
let start_xpos = NotNan::new(params.source_origin_x as f32 / params.image_width as f32)
.context("computing xpos")?;
@@ -256,9 +256,13 @@ pub(crate) fn check_image_dimensions(width: u32, height: u32) -> anyhow::Result<
SizeFormatter::new(MAX_IMAGE_SIZE, DECIMAL),
);
}
if size == 0 {
anyhow::bail!("Ignoring image with 0x0 dimensions");
}
Ok(())
}
#[derive(Debug)]
pub(crate) struct ImageInfo {
pub width: u32,
pub height: u32,
+9 -1
View File
@@ -35,7 +35,15 @@ impl TerminalState {
};
if let Err(err) = check_image_dimensions(info.width, info.height) {
log::error!("{}", err);
log::error!("{err:#}, {info:#?}");
return;
}
if self.pixel_width == 0 || self.pixel_height == 0 {
error!(
"my pixel dimensions are wacky! {}x{}",
self.pixel_width, self.pixel_height
);
return;
}