I have the following YAML:
family:
- title: Parent
children:
- title: kid1
- title: kid2
- title: Uncle
on adding another kid like so:
editor.appendToList(['family', 0, 'children'], {'title': 'kid3'});
the following exception is thrown:
Assertion failed: (package:yaml_edit) Failed to produce valid YAML after modification.
The full code to reproduce the issue is as follows:
import 'package:yaml_edit/yaml_edit.dart';
void main() {
final yaml = '''
family:
- title: Parent
children:
- title: kid1
- title: kid2
- title: Uncle
''';
print('--- BEFORE ---');
print(yaml);
final editor = YamlEditor(yaml);
editor.appendToList(['family', 0, 'children'], {'title': 'kid3'});
print('--- AFTER (buggy yaml_edit) ---');
print(editor.toString());
print('--- EXPECTED ---');
print('''
family:
- title: Parent
children:
- title: kid1
- title: kid2
- title: kid3
- title: Uncle
''');
}
The issue is coming because:
list.nodes.last.span.end.offset gives offset for character just before "- title: Uncle".
The fix is following:
#2482
I have the following YAML:
on adding another kid like so:
editor.appendToList(['family', 0, 'children'], {'title': 'kid3'});the following exception is thrown:
Assertion failed: (package:yaml_edit) Failed to produce valid YAML after modification.The full code to reproduce the issue is as follows:
The issue is coming because:
list.nodes.last.span.end.offsetgives offset for character just before "- title: Uncle".The fix is following:
#2482