From e72446659036a035f31a8b577a56e5fd9e874632 Mon Sep 17 00:00:00 2001 From: singerdmx Date: Mon, 21 Dec 2020 21:30:11 -0800 Subject: [PATCH] Fix line retain --- lib/models/documents/nodes/line.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/models/documents/nodes/line.dart b/lib/models/documents/nodes/line.dart index 537a14b8..2727e101 100644 --- a/lib/models/documents/nodes/line.dart +++ b/lib/models/documents/nodes/line.dart @@ -56,6 +56,13 @@ class Line extends Container { @override String toPlainText() => super.toPlainText() + '\n'; + @override + String toString() { + final body = children.join(' → '); + final styleString = style.isNotEmpty ? ' $style' : ''; + return '¶ $body ⏎$styleString'; + } + @override insert(int index, Object data, Style style) { if (data is Embeddable) { @@ -98,12 +105,13 @@ class Line extends Container { } int thisLen = this.length; - int local = math.min(thisLen - index, length); - assert(style.values.every((attr) => attr.scope == AttributeScope.BLOCK)); + int local = math.min(thisLen - index, len); if (index + local == thisLen && local == 1) { + assert(style.values.every((attr) => attr.scope == AttributeScope.BLOCK)); _format(style); } else { + assert(style.values.every((attr) => attr.scope == AttributeScope.INLINE)); assert(index + local != thisLen); super.retain(index, local, style); }