From 2d58609d546e1c1ede537071aa7de38fc06d1529 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sun, 2 Jan 2022 18:49:28 +0000 Subject: [PATCH] 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 --- src/display.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/display.rs b/src/display.rs index 4f0124b..d904a7c 100644 --- a/src/display.rs +++ b/src/display.rs @@ -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;