mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 08:25:50 +03:00
term: improve readability of error message for oversized image
refs: https://github.com/wez/wezterm/issues/3264
This commit is contained in:
parent
a115fc0df7
commit
97452d0ccc
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -2126,6 +2126,15 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
||||
dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
@ -2537,6 +2546,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.24.2"
|
||||
@ -6064,6 +6079,7 @@ dependencies = [
|
||||
"env_logger",
|
||||
"finl_unicode",
|
||||
"hex",
|
||||
"humansize",
|
||||
"image",
|
||||
"k9",
|
||||
"lazy_static",
|
||||
|
@ -17,6 +17,7 @@ use_serde = ["termwiz/use_serde"]
|
||||
anyhow = "1.0"
|
||||
bitflags = "1.3"
|
||||
csscolorparser = "0.6"
|
||||
humansize = "2.1"
|
||||
miniz_oxide = "0.4"
|
||||
finl_unicode = "1.2"
|
||||
hex = "0.4"
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::{Position, StableRowIndex, TerminalState};
|
||||
use anyhow::Context;
|
||||
use humansize::{SizeFormatter, DECIMAL};
|
||||
use ordered_float::NotNan;
|
||||
use std::sync::Arc;
|
||||
use termwiz::cell::Cell;
|
||||
@ -244,11 +245,12 @@ pub(crate) fn check_image_dimensions(width: u32, height: u32) -> anyhow::Result<
|
||||
let size = width.saturating_mul(height).saturating_mul(4);
|
||||
if size > MAX_IMAGE_SIZE {
|
||||
anyhow::bail!(
|
||||
"Ignoring image data {}x{} because {} bytes > max allowed {}",
|
||||
"Ignoring image data for image with dimensions {}x{} \
|
||||
because required RAM {} > max allowed {}",
|
||||
width,
|
||||
height,
|
||||
size,
|
||||
MAX_IMAGE_SIZE
|
||||
SizeFormatter::new(size, DECIMAL),
|
||||
SizeFormatter::new(MAX_IMAGE_SIZE, DECIMAL),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user