Skip to main content

Module coordinates

Module coordinates 

Source
Expand description

Graph positions to edit-plan positions.

These are two different coordinate systems and nothing warns you when they are confused: the graph records a 1-based byte column, the edit plan carries a 0-based UTF-16 character offset. They agree on every ASCII line, which is exactly why a mix-up survives testing and then corrupts the first file with an accented name or an emoji in a comment.

Every conversion here refuses rather than clamps. A column past the end of its line means the graph no longer describes the file, and silently landing an edit at the nearest valid offset would write bytes nobody planned.

Enums§

PositionError
A position that could not be converted, with the reason an agent can act on.

Functions§

slice_between
The exact text between two graph positions, or None when either does not convert.
utf16_line_length
The UTF-16 length of a whole line, for an edit that ends where the line does.
utf16_offset
The 0-based UTF-16 offset of a 1-based byte column on a 1-based line.