Skip to main content

normalize_range

Function normalize_range 

Source
pub fn normalize_range(
    start: usize,
    end: usize,
) -> Result<(usize, usize), FcError>
Expand description

Normalizes a text offset pair into a half-open range [start, end).

Half-open is the convention throughout the workspace: it composes with slicing, and start == end naturally expresses a caret rather than needing a separate “is this a selection” flag.

A backwards range is an error rather than a silent swap. A caller computing one has a bug, and quietly fixing it hides that bug while surfacing its symptom somewhere unrelated.