Fixed bug with word wrapping when a word is longer than a line.
This commit is contained in:
parent
dbb640b330
commit
54a16c6383
|
@ -267,6 +267,7 @@ where
|
|||
self.indent_found = true;
|
||||
}
|
||||
|
||||
if self.pos.1 > 0 {
|
||||
if self.f.maintain_indent {
|
||||
self.pos = (
|
||||
self.pos.0 + self.f.single_line_height(),
|
||||
|
@ -279,6 +280,7 @@ where
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.word_i = 0;
|
||||
}
|
||||
|
@ -356,6 +358,58 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dimensions_3() {
|
||||
// 55 graphemes long
|
||||
let text = "税マイミ文末\
|
||||
レ日題イぽじ\
|
||||
や男目統ス公\
|
||||
身みトしつ結\
|
||||
煮ヱマレ断西\
|
||||
ロ領視りいぽ\
|
||||
凱字テ式重反\
|
||||
てす献罪がご\
|
||||
く官俵呉嫁ー\
|
||||
。";
|
||||
|
||||
let mut f = ConsoleLineFormatter::new(4);
|
||||
f.wrap_type = WrapType::CharWrap(0);
|
||||
f.maintain_indent = false;
|
||||
f.wrap_additional_indent = 0;
|
||||
f.set_wrap_width(12);
|
||||
|
||||
assert_eq!(
|
||||
f.dimensions(UnicodeSegmentation::graphemes(text, true)),
|
||||
(10, 12)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dimensions_4() {
|
||||
// 55 graphemes long
|
||||
let text = "税マイミ文末\
|
||||
レ日題イぽじ\
|
||||
や男目統ス公\
|
||||
身みトしつ結\
|
||||
煮ヱマレ断西\
|
||||
ロ領視りいぽ\
|
||||
凱字テ式重反\
|
||||
てす献罪がご\
|
||||
く官俵呉嫁ー\
|
||||
。";
|
||||
|
||||
let mut f = ConsoleLineFormatter::new(4);
|
||||
f.wrap_type = WrapType::WordWrap(0);
|
||||
f.maintain_indent = false;
|
||||
f.wrap_additional_indent = 0;
|
||||
f.set_wrap_width(12);
|
||||
|
||||
assert_eq!(
|
||||
f.dimensions(UnicodeSegmentation::graphemes(text, true)),
|
||||
(10, 12)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_to_v2d_1() {
|
||||
let text = "Hello there, stranger!"; // 22 graphemes long
|
||||
|
|
Loading…
Reference in New Issue
Block a user