From 350d7bcfb038c90079a3002e0630a0554e1322f9 Mon Sep 17 00:00:00 2001 From: Nicolas Dion-Bouchard Date: Mon, 7 Feb 2022 16:16:59 -0500 Subject: [PATCH] Fix for undoing a modification ending with an indented line (#656) Co-authored-by: Nicolas Dion Bouchard --- lib/src/models/rules/insert.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/models/rules/insert.dart b/lib/src/models/rules/insert.dart index f1db6318..70c1e63e 100644 --- a/lib/src/models/rules/insert.dart +++ b/lib/src/models/rules/insert.dart @@ -115,7 +115,11 @@ class PreserveBlockStyleOnInsertRule extends InsertRule { delta.insert('\n', lineStyle.toJson()); } else if (i < lines.length - 1) { // we don't want to insert a newline after the last chunk of text, so -1 - delta.insert('\n', blockStyle); + final blockAttributes = blockStyle.isEmpty + ? null + : blockStyle.map((_, attribute) => + MapEntry(attribute.key, attribute.value)); + delta.insert('\n', blockAttributes); } }