MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / position_to_offset

Function position_to_offset

src/util.rs:721–723  ·  view source on GitHub ↗

Convert an LSP Position (line, character) to a byte offset in content. Thin wrapper around [`position_to_byte_offset`] that returns `u32` (matching the offset type used by `ClassInfo::start_offset` / `end_offset` and `ResolutionCtx::cursor_offset`).

(content: &str, position: Position)

Source from the content-addressed store, hash-verified

719/// (matching the offset type used by `ClassInfo::start_offset` /
720/// `end_offset` and `ResolutionCtx::cursor_offset`).
721pub(crate) fn position_to_offset(content: &str, position: Position) -> u32 {
722 position_to_byte_offset(content, position) as u32
723}
724
725/// Convert an LSP `Position` (line/character) to a character offset into
726/// a pre-built char array.

Calls 1

position_to_byte_offsetFunction · 0.85

Tested by

no test coverage detected