🪨 X marks the spot
Round-trip mode has always known where every node came from. v0.5.0 makes that reachable by data path.
document.locate(["servers", 1, "port"]) walks a path of mapping keys and list indices and hands back the node at that location, scalar leaves included, with its line, column, file, and exact range. Item access cannot do this: it unwraps a scalar to its bare value, leaving nowhere to hang a position. locate always returns a positioned handle, so a tool that validates the loaded data and reports a failure by its path into that data can turn the path into an exact file:line:column, right down to a leaf, and follow it through !include boundaries to the file the value actually lives in. Nodes also gained a range() for underlining the full span in an editor.
While wiring this up we found the round-trip cursor disagreed with the loader on a document with a duplicate mapping key: the loader keeps the last value, the cursor was reading the first. They now agree, so reads, locate, keys, len, set, and delete all act on the same effective entry loads returns. (Duplicate keys are still rejectable outright with OPT_DUPLICATE_KEYS_ERROR.)
pip install yamlrocks📚 Docs: https://yaml.rocks
Same rock. X marks the spot. 🪨
../Frenck
 Â
 Â
 Â
 Â
 Â
 Â
 Â
 Â
Blogging my personal ramblings at frenck.dev