Skip to main content

Module view

Module view 

Source
Expand description

Pure line-selection helpers behind ct-view’s bounded, context-aware reads: parsing a --range spec, expanding --match hits into context windows, and grouping the kept line indices into contiguous runs for display.

Functions§

expand_and_merge
Expand each hit index by ctx lines and merge overlapping/adjacent windows into a sorted, de-duplicated list of line indices, clamped to total lines.
parse_range
Parse a --range spec into a 0-based inclusive [start, end], clamped to a file of total lines. Returns None when the range selects nothing.
segments
Group sorted indices into contiguous [start, end] runs (the display groups separated by -- in text output).