-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spans for nested map values are needlessly multi-line #51
Comments
Fixes #51 Also remove dead line from changelog
Fixes #51 Also remove dead line from changelog
Fixes #51 Also remove dead line from changelog
Fix was reverted in a0ecc98 |
Hi @kevmoo, the bug seems to be due to scanner returning a token with incorrect span. The _scanPlainScalar moves ahead after finding a blank or break and modifies the 'end' variable responsible for identifying total span of the token. I have tried to break out of the _scanPlainScalar while loop if no plain character is found (adarshm-26@e816122) and it does fix this issue. |
Include tests, make sure travis is green, that's a good start |
The bug is more pronounced when using a raw yaml string, import 'package:yaml/yaml.dart';
void main() {
const dtr =
'''
'nested_0': {
'nested_1': {
'nested_2': {
'n2k1': null
,
'n2k2': a
,
'n2k3': 4
},
'n1k2': 425
},
'n0k2': aval
,
}
'rk2': 44
,
''';
final yaml = loadYaml(dtr) as YamlMap;
final yaml_n1 = yaml.nodes['nested_0'] as YamlMap;
final yaml_n2 = yaml_n1.nodes['nested_1'] as YamlMap;
final yaml_n3 = yaml_n2.nodes['nested_2'] as YamlMap;
print(yaml.nodes['rk2'].span.message('Root last entry span, trailing space upto next line'));
print(yaml_n1.nodes['n0k2'].span.message('Level 1 nested last entry span, trailing space upto comma(,)'));
print(yaml_n2.nodes['n1k2'].span.message('Level 2 nested last entry span, trailing space upto curly brace(})'));
print(yaml_n3.nodes['n2k1'].span.message('Level 3 nested first entry span, trailing space upto comma(,)'));
print(yaml_n3.nodes['n2k2'].span.message('Level 3 nested mid entry span, trailing space upto comma(,)'));
print(yaml_n3.nodes['n2k3'].span.message('Level 3 nested last entry span, trailing space upto curly brace(})'));
} Output
the spec says - "Flow collections entries are terminated by the "," indicator. The final "," may be omitted". This might imply that their span should extend to the "," indicator, but in its absence it extends upto curly braces. The fix I suggested is wrong in this case, removing the PR. Treating the last entry separately could help. |
Fixes dart-lang/yaml#51 Also remove dead line from changelog
This reverts commit cb3cf76. dart-lang/yaml#51 only seems to affect JSON-encoded source files. Not worth this hack.
Accessing the span for a node in a nested map renders it (needlessly) multiline if it's the LAST item in a map.
Not an issue for root items, though...
output
The text was updated successfully, but these errors were encountered: