Skip to main content

Module TextEdit

Expand description

Pure text-editing utilities shared across workspace and document providers.

These are side-effect-free helper functions that compute line offsets and translate (line, character) positions to byte offsets, matching VS Code’s UTF-16 code unit counting convention for Range/Position values.

Functions§

ComputeLineOffsets
Pre-compute the byte offset of the start of every line in Source. The returned vec always has at least one entry ([0]).
LinePosToOffset
Resolve (line, character) to an absolute byte offset in Source. character is counted in UTF-16 code units to match VS Code’s Range/Position semantics. Falls back to EOF when line/character exceeds the source length.
hex_digit 🔒
percent_decode
Minimal percent-decoder for file:// URI paths. Self-contained to avoid an extra crate dependency; handles %XX sequences only.