When the value is empty the SourceSpan for the YamlNode representing
the value in a map points to the colon.
Example:
foo:
bar:
The YamlNode for foo.bar has a value of null and starts and ends
at the colon : following bar. This means that removal might leave
the colon behind, which causes invalid YAML.
We have the same issue when removing foo.bar from the following YAML
document:
foo:
baz: true
bar:
However, in this case, we have a hack that ensures we always strip away
the any comments that follows bar. We do this by deleting up-to the
next newline. If we apply the same hack when removing foo.bar in the
first example, then it works.
One could argue that it works by accident, but it's kind of desired that
trailing comments are removed, when the value they are trailing is
removed.
please double check golden files during review
Fixes https://github.com/dart-lang/yaml_edit/issues/55.
When the value is empty the
SourceSpan
for theYamlNode
representing the value in a map points to the colon.Example:
The
YamlNode
forfoo.bar
has a value ofnull
and starts and ends at the colon:
followingbar
. This means that removal might leave the colon behind, which causes invalid YAML.We have the same issue when removing
foo.bar
from the following YAML document:However, in this case, we have a hack that ensures we always strip away the any comments that follows
bar
. We do this by deleting up-to the next newline. If we apply the same hack when removingfoo.bar
in the first example, then it works.One could argue that it works by accident, but it's kind of desired that trailing comments are removed, when the value they are trailing is removed.