dart-lang / yaml_edit

A library for YAML manipulation with comment and whitespace preservation.
https://pub.dev/packages/yaml_edit
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link

Adding a new key/value to a Map with a non-scalar value leaves trailing whitespace #15

Closed srawlins closed 2 years ago

srawlins commented 2 years ago

See this example:

import 'package:yaml_edit/yaml_edit.dart';

void main() {
  final yamlEditor = YamlEditor('''
analyzer:
  a:
    b: true
''');
  yamlEditor.update(['analyzer', 'language'], {'strict-casts': true});
  var lines = yamlEditor.toString().split('\n');
  print(lines.map((l) => "'$l'").join('\n'));
}

This results in this output, note the trailing space after language::

'analyzer:'
'  a:'
'    b: true'
'  language: '
'    strict-casts: true'
''