Fix line endings for inserted maps on Windows (dart-lang/yaml_edit#66)

Fixes https://github.com/dart-lang/yaml_edit/issues/65
diff --git a/pkgs/yaml_edit/CHANGELOG.md b/pkgs/yaml_edit/CHANGELOG.md
index d732b1a..7213676 100644
--- a/pkgs/yaml_edit/CHANGELOG.md
+++ b/pkgs/yaml_edit/CHANGELOG.md
@@ -1,4 +1,8 @@
 ## 2.2.0
+
+- Fix inconsistent line endings when inserting maps into a document using `\r\n`.
+  ([#65](https://github.com/dart-lang/yaml_edit/issues/65))
+
 - `AliasError` is changed to `AliasException` and exposed in the public API.
 
   All node-mutating methods on `YamlEditor`, i.e. `update()`, `appendToList()`,
@@ -13,6 +17,7 @@
 - Require Dart 2.19
 
 ## 2.1.0
+
 - **Breaking** `wrapAsYamlNode(value, collectionStyle, scalarStyle)` will apply
   `collectionStyle` and `scalarStyle` recursively when wrapping a children of
   `Map` and `List`.
@@ -26,18 +31,22 @@
   ([#23](https://github.com/dart-lang/yaml_edit/issues/23))
 
 ## 2.0.3
+
 - Updated the value of the pubspec `repository` field.
 
 ## 2.0.2
+
 - Fix trailing whitespace after adding new key with block-value to map
   ([#15](https://github.com/dart-lang/yaml_edit/issues/15)).
 - Updated `repository` and other meta-data in `pubspec.yaml`.
 
 ## 2.0.1
+
 - License changed to BSD, as this package is now maintained by the Dart team.
 - Fixed minor lints.
 
 ## 2.0.0
+
 - Migrated to null-safety.
 - API will no-longer return `null` in-place of a `YamlNode`, instead a
   `YamlNode` with `YamlNode.value == null` should be used. These are easily
diff --git a/pkgs/yaml_edit/lib/src/strings.dart b/pkgs/yaml_edit/lib/src/strings.dart
index 8767c1b..41994b9 100644
--- a/pkgs/yaml_edit/lib/src/strings.dart
+++ b/pkgs/yaml_edit/lib/src/strings.dart
@@ -274,7 +274,7 @@
       /// Empty collections are always encoded in flow-style, so new-line must
       /// be avoided
       if (isCollection(entry.value) && !isEmpty(entry.value)) {
-        return '$formattedKey:\n$formattedValue';
+        return '$formattedKey:$lineEnding$formattedValue';
       }
 
       return '$formattedKey: $formattedValue';
diff --git a/pkgs/yaml_edit/test/windows_test.dart b/pkgs/yaml_edit/test/windows_test.dart
index a516204..50f79e7 100644
--- a/pkgs/yaml_edit/test/windows_test.dart
+++ b/pkgs/yaml_edit/test/windows_test.dart
@@ -167,6 +167,25 @@
       expectYamlBuilderValue(doc, []);
     });
 
+    test('inserted nested map', () {
+      final doc = YamlEditor('''
+a:\r
+  b:\r
+''');
+      doc.update(
+        ['a', 'b'],
+        {
+          'c': {'d': 'e'}
+        },
+      );
+      expect(doc.toString(), equals('''
+a:\r
+  b:\r
+    c:\r
+      d: e\r
+'''));
+    });
+
     test('remove from block map', () {
       final doc = YamlEditor('''
 a: 1\r