Span
Given the original YAML source text and a path through the document
(e.g. ["sources", "brew", "version"]), this module returns the
super::Span of the matching key so diagnostic renderers can
underline the exact region of the user’s file.
Algorithm
The mapper scans the YAML source line-by-line. For each key-path component it looks for a line that:
- Begins at the expected indentation level (two-space YAML indent assumed, common in stackie block files and serde_yaml output).
- Starts with the expected key name followed by
:.
When the full path is consumed the span covers that single key line. This handles the vast majority of block/stack validation errors without requiring a full YAML scanner with position tracking.
Limitations
- Assumes two-space indentation (consistent with all stackie YAML files).
- Does not handle multi-document YAML or aliases.
- Returns
Nonewhen the key path is empty or the key is not found.