concat method

SpannedString concat(
  1. SpannedString other
)

Concatenate another spanned string with this one and return the result.

Touching spans with the same attribute will be merged.

Implementation

SpannedString concat(SpannedString other) {
  return SpannedString.chars(
    text + other.text,
    other.spans
        .shift(0, text.length)
        .iter
        .fold(spans, (ls, s) => ls.merge(s)),
  );
}