Skip to main content

segment_at_position

Function segment_at_position 

Source
pub fn segment_at_position(
    pattern: &ParsedPattern,
    caret_pos: usize,
) -> Option<(usize, usize, SegmentKind)>
Expand description

Find the segment under caret_pos (in formatted-text display coordinates). A caret resting on a segment boundary belongs to the segment to its right (typing-into semantics). A caret on a separator snaps to the preceding segment so Up/Down keep working when the caret is between two segments. Returns None only when the pattern has no editable segments at all.