Replies: 1 comment 3 replies
-
You've managed to hit one of the issues (the handling of empty nodes) that lead me to rewrite the parser for The new parser has been merged into the const doc = YAML.parseDocument(`name: \nage: 26`)
doc.contents.items[0].value
// Scalar { value: null, range: [ 12, 12 ], source: '', type: 'PLAIN' } That range ought to be |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
is a list of objects of type 'PAIR' that have a key and value property.
Each key and value provide a
range
field that is very useful to figure out the exact location in the original text. Unfortunately, forname
in this example the values is simplynull
so it is not possible to obtain the range. How can we get this range?I tried
which seems to be an alternating list of objects of type
PLAIN
andMAP_VALUE
which provide arange
field even for the 'null' value ofname
. The range we get for theMAP_VALUE
corresponding toname
is exactly what I am looking for. But unfortunately if I write the same YAML asdoc.contents.cstNode.items
will be an array of some objects with typePLAIN
(forname
,age
and26
) and some nodes that simply provide acharacter
andoffset
(for{
,:
,,
and}
). So this does not seem to be a reliable way to obtain the character range of thename
value (in case it is null).My use-case is that I want to provide auto-completion for the
name
field and for this I need to detect the position of the name value in the YAML document. My current workaround is basing the value range on the range of the key, but that is not ideal either.Beta Was this translation helpful? Give feedback.
All reactions