Skip to content

Commit

Permalink
refactor(line): turn multiline content into spans
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Sep 22, 2023
1 parent 390872d commit 9d4db84
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/text/line.rs
Expand Up @@ -25,7 +25,11 @@ impl<'a> Line<'a> {
T: Into<Cow<'a, str>>,
{
Line {
spans: vec![Span::raw(content)],
spans: content
.into()
.lines()
.map(|v| Span::raw(v.to_string()))
.collect(),
alignment: None,
}
}
Expand Down Expand Up @@ -348,5 +352,9 @@ mod tests {
let line = Line::raw("test content");
assert_eq!(line.spans, vec![Span::raw("test content")]);
assert_eq!(line.alignment, None);

let line = Line::raw("a\nb");
assert_eq!(line.spans, vec![Span::raw("a"), Span::raw("b")]);
assert_eq!(line.alignment, None);
}
}

0 comments on commit 9d4db84

Please sign in to comment.