From d2e3784b778bf53ce7ad0b91480db8fa5ceb4e0b Mon Sep 17 00:00:00 2001 From: Cat <114286961+CatHood0@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:21:55 -0400 Subject: [PATCH] Fix(rule): PreserveInlineStyleRule assume the type of the operation data and throw stacktrace (#2028) --- lib/src/models/rules/insert.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/models/rules/insert.dart b/lib/src/models/rules/insert.dart index 7ea7050d..d09bb452 100644 --- a/lib/src/models/rules/insert.dart +++ b/lib/src/models/rules/insert.dart @@ -568,8 +568,9 @@ class PreserveInlineStylesRule extends InsertRule { if (prevData.endsWith('\n')) { /// If current line is empty get attributes from a prior line final currLine = itr.next(); - final currData = currLine.data as String?; - if (currData != null && (currData.isEmpty || currData[0] == '\n')) { + final currData = + currLine.data is String ? currLine.data as String : null; + if (currData?.isEmpty == true || currData?.startsWith('\n') == true) { if (prevData.trimRight().isEmpty) { final back = DeltaIterator(documentDelta).skip(index - prevData.length);