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:
parent
90d1cbe3e4
commit
6f173f11f3
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user