TextDocument: Don't leave empty paragraphs when inserting line-breaks.

Instead, add one empty TextSpan. This commit resolves the last of the
very obvious problems when editing. More subtle ones may still surface.
This commit is contained in:
Stephan Aßmus 2014-01-26 15:17:52 +01:00
parent 90d1cbe3e4
commit 6f173f11f3

View File

@ -155,6 +155,14 @@ TextDocument::Insert(int32 textOffset, const BString& text,
chunkStart = chunkEnd + 1;
}
if (paragraph2.IsEmpty()) {
// Make sure Paragraph has at least one TextSpan, even
// if its empty.
const TextSpanList& spans = paragraph1.TextSpans();
const TextSpan& span = spans.LastItem();
paragraph2.Append(TextSpan("", span.Style()));
}
if (!fParagraphs.Add(paragraph2, index))
return B_NO_MEMORY;
} else {