From d2f2f642c16fb0995f8d7f7a59d8529577558ac9 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 1 Aug 2017 09:44:40 -0700 Subject: [PATCH] Protect LinesIterator from zero width Fixes #147 --- src/utils/lines_iterator.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/lines_iterator.rs b/src/utils/lines_iterator.rs index c89bcd4..65de257 100644 --- a/src/utils/lines_iterator.rs +++ b/src/utils/lines_iterator.rs @@ -99,7 +99,11 @@ impl<'a> Iterator for LinesIterator<'a> { let content = &content[..next]; let allowed_width = if self.show_spaces { - self.width - 1 + if self.width < 1 { + 0 + } else { + self.width - 1 + } } else { self.width };