pub fn byte_column_to_position(
source: &str,
row: usize,
byte_column: usize,
byte_offset: usize,
) -> PositionExpand description
Convert a tree-sitter node boundary into a Position, without rescanning
the file.
byte_offset_to_position walks from byte 0 on every call, which is fine
once per request but quadratic when a whole syntax tree is converted node by
node. Tree-sitter already reports row and a byte_column measured from the
start of that row, so the line begins at byte_offset - byte_column and only
that prefix has to be measured.
Taking row from tree-sitter also keeps the result in the same line model as
the tree being walked; TextIndex treats U+2028/U+2029 as line terminators
and tree-sitter does not, so deriving the row here instead would put symbols
on a different line than the node they came from.