Skip to main content

source_byte_to_display_col

Function source_byte_to_display_col 

Source
pub fn source_byte_to_display_col(
    byte: u32,
    inlay_offsets: &[(u32, u32)],
    conceals: &[ConcealRange],
) -> u32
Expand description

Map a source byte to its display column.

inlay_offsets are (orig_byte, extra_cols) splices that add columns; conceals are ranges that remove them. Both are in the same already-char-resolved space the rest of the cell substrate uses — see the byte-vs-char note on crate::row::CellRow::byte_to_combined_col. In that space a hidden range removes exactly end - start columns, which is why conceal needs no width table of its own.

§A byte inside a concealed range

It has no column of its own, and it resolves to the column of its range’s start — the first visible position at or before it. That is not a special case in the code below: subtracting only the concealed width that lies strictly before byte yields the range’s start column on its own.

Landing there is deliberate. The alternative — letting the subtraction run past byte — produces a column between the range’s endpoints, which is worse than either end precisely because it looks plausible: a caret one column into a hidden span reads as an off-by-one in the shaper rather than as a missing rule.