pub fn char_col_for_visual_offset(
line: &str,
seg: (usize, usize),
visual_offset: usize,
) -> usizeExpand description
Inverse of the per-char accounting wrap_segments uses to find where a
segment breaks: map a visual x offset (visual_offset, cells counted
from the segment’s OWN left edge — i.e. 0 at seg.0, matching how the
renderer paints each wrapped row starting at its text area’s left
column regardless of seg.0) to the char index within seg = [start, end) it lands on.
Uses the exact same per-char width formula wrap_segments sums to find
segment boundaries (char::width().unwrap_or(1).max(1)), so a click
that wrap_segments would consider inside this segment resolves to the
same character wrap_segments wrapped around. This does NOT reproduce
the renderer’s real tab-stop expansion (wrap_segments itself counts a
tab as 1 cell, not tabstop cells) — that mismatch predates this
function and is wrap_segments’ own documented simplification; mouse
click mapping mirrors it for round-trip consistency with the wrap
engine rather than inventing a different tab model for wrapped rows.
Clamps to end (one past the segment’s last char) once cumulative
width reaches or exceeds visual_offset — vim’s “past EOL on this
visual row” landing spot.