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:
@@ -155,6 +155,14 @@ TextDocument::Insert(int32 textOffset, const BString& text,
|
|||||||
chunkStart = chunkEnd + 1;
|
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))
|
if (!fParagraphs.Add(paragraph2, index))
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user