summaryrefslogtreecommitdiffstats
path: root/src/draw.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2019-10-13 22:38:00 -0700
committerDan Davison <dandavison7@gmail.com>2019-10-13 22:45:55 -0700
commit8e4ade1bf1ed4a6b0b453af8e2ff6c7168df0b59 (patch)
tree52dba8846ce5390c6469c06db88ade8d2b7626a6 /src/draw.rs
parent3280e66def4d41d7c8cb503c4e59a4eacd71268e (diff)
Don't compute negative line lengths
Fixes #18
Diffstat (limited to 'src/draw.rs')
-rw-r--r--src/draw.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/draw.rs b/src/draw.rs
index 7211e620..6ec3a84f 100644
--- a/src/draw.rs
+++ b/src/draw.rs
@@ -36,7 +36,16 @@ pub fn write_boxed_with_line(
) -> std::io::Result<()> {
let box_width = strip_ansi_codes(text).graphemes(true).count() + 1;
write_boxed_with_horizontal_whisker(writer, text, box_width, line_style, heavy)?;
- write_horizontal_line(writer, line_width - box_width - 1, line_style, heavy)?;
+ write_horizontal_line(
+ writer,
+ if line_width > box_width {
+ line_width - box_width - 1
+ } else {
+ 0
+ },
+ line_style,
+ heavy,
+ )?;
Ok(())
}