fix: preserve_line_style assume the type of the operation data

pull/2023/head
CatHood0 9 months ago
parent 7c72967861
commit 9a7c5ab107
  1. 20
      lib/src/models/rules/insert.dart

@ -568,17 +568,19 @@ class PreserveInlineStylesRule extends InsertRule {
if (prevData.endsWith('\n')) { if (prevData.endsWith('\n')) {
/// If current line is empty get attributes from a prior line /// If current line is empty get attributes from a prior line
final currLine = itr.next(); final currLine = itr.next();
final currData = currLine.data as String?; if (currLine.data is String) {
if (currData != null && (currData.isEmpty || currData[0] == '\n')) { final currData = currLine.data as String?;
if (prevData.trimRight().isEmpty) { if (currData != null && (currData.isEmpty || currData[0] == '\n')) {
final back = if (prevData.trimRight().isEmpty) {
DeltaIterator(documentDelta).skip(index - prevData.length); final back =
if (back != null && back.data is String) { DeltaIterator(documentDelta).skip(index - prevData.length);
prev = back; if (back != null && back.data is String) {
prev = back;
}
} }
} else {
prev = currLine;
} }
} else {
prev = currLine;
} }
} }
} }

Loading…
Cancel
Save