Fix: Add assert for low terminal width

If terminal is not wide enought to print text, then print an error
message

https://github.com/bootandy/dust/issues/204
This commit is contained in:
andy.boot
2022-01-02 18:49:28 +00:00
parent 109a0b90d4
commit 2d58609d54
+4
View File
@@ -128,6 +128,10 @@ pub fn draw_it(
} else {
5 // Under normal usage we need 5 chars to display the size of a directory
};
assert!(
terminal_width > 9 + num_chars_needed_on_left_most,
"Not enough terminal width"
);
let terminal_width = terminal_width - 9 - num_chars_needed_on_left_most;
let num_indent_chars = 3;