mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
use split_inclusive instead
This commit is contained in:
parent
863e11d5e3
commit
a65ef892ca
@ -36,20 +36,15 @@ impl<'a> Write for TuiLog<'a> {
|
|||||||
|
|
||||||
for out in line.ansi_parse() {
|
for out in line.ansi_parse() {
|
||||||
match out {
|
match out {
|
||||||
Output::TextBlock(mut text) => {
|
Output::TextBlock(text) => {
|
||||||
// search for newlines (.lines() or .split doesn't work, as this block does not
|
// search for newlines
|
||||||
// need to contain one)
|
for t in text.split_inclusive('\n') {
|
||||||
while let Some(newline) = text.find('\n') {
|
span.content.to_mut().push_str(&t);
|
||||||
span.content.to_mut().push_str(&text[..newline]);
|
if t.ends_with('\n') && span.content.len() != 0 {
|
||||||
if span.content.len() != 0 {
|
spans.push(std::mem::replace(&mut span, Span::raw("")));
|
||||||
spans.push(span);
|
lines.push(std::mem::take(&mut spans));
|
||||||
lines.push(spans);
|
|
||||||
spans = Vec::new();
|
|
||||||
span = Span::raw("");
|
|
||||||
}
|
}
|
||||||
text = &text[newline + 1..];
|
|
||||||
}
|
}
|
||||||
span.content.to_mut().push_str(text);
|
|
||||||
},
|
},
|
||||||
Output::Escape(seq) => {
|
Output::Escape(seq) => {
|
||||||
if span.content.len() != 0 {
|
if span.content.len() != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user