Skip to main content

find_instance_path_span

Function find_instance_path_span 

Source
pub fn find_instance_path_span(
    content: &str,
    instance_path: &str,
) -> (usize, usize)
Expand description

Find the byte span (offset, length) of a JSON pointer path segment in the source text, suitable for converting directly into a SourceSpan.

For an instance_path like /properties/name, searches for the last segment name as a JSON key ("name") or YAML key (name:), and returns a span covering the matched token.

For root-level errors (empty or “/” path), skips past leading comment and blank lines so the error arrow points at actual content rather than modeline comments. The returned span has zero length in this case since there is no specific token.

Falls back to (0, 0) if nothing is found.