pub enum PositionEncoding {
Utf8,
Utf16,
Utf32,
}Expand description
The character-unit convention a client uses for Position.character.
LSP 3.17+ clients advertise the encodings they support via the
general.positionEncodings client capability and the server picks one in
its InitializeResult; older clients always mean UTF-16. All conversions
in this crate funnel through this enum.
Variants§
Utf8
Position.character counts UTF-8 bytes (code units of UTF-8).
Utf16
Position.character counts UTF-16 code units — the LSP default and
what most clients (VS Code included) use.
Utf32
Position.character counts Unicode code points (UTF-32 code units).
Implementations§
Source§impl PositionEncoding
impl PositionEncoding
Sourcepub fn capability(self) -> PositionEncodingKind
pub fn capability(self) -> PositionEncodingKind
The capability to advertise in InitializeResult.capabilities.position_encoding.
Sourcepub fn negotiate(offered: &[PositionEncodingKind]) -> Option<Self>
pub fn negotiate(offered: &[PositionEncodingKind]) -> Option<Self>
Selects an encoding from a client-advertised capability list, preferring UTF-8 (cheapest to convert) over UTF-16 over UTF-32.
Returns None — and callers should fall back to
PositionEncoding::Utf16, the LSP default — if the client
advertises none of the supported encodings.