Module DocumentStateDTO

Module DocumentStateDTO 

Source
Expand description

§DocumentStateDTO

§RESPONSIBILITY

  • Data transfer object for text document state
  • Serializable format for gRPC/IPC transmission
  • Used by Mountain to track document lifecycle and sync with Air

§FIELDS

  • URI: Unique document resource identifier
  • LanguageIdentifier: Language ID for syntax highlighting
  • Version: Client-side version for change tracking
  • Lines: Document content split into lines
  • EOL: End-of-line sequence (\n or \r\n)
  • IsDirty: Indicates unsaved changes
  • Encoding: File encoding (e.g., utf8)
  • VersionIdentifier: Internal version for host tracking

TODO (Mountain→Air Split): If Air implements a background document sync service, consider delegating delta change validation or conflict resolution to Air. For now, Mountain handles this synchronously to ensure UI responsiveness.

Structs§

DocumentStateDTO
Represents the complete in-memory state of a single text document.

Constants§

MAX_DOCUMENT_LINES 🔒
Maximum line count for a document to prevent memory exhaustion
MAX_LANGUAGE_ID_LENGTH 🔒
Maximum language identifier string length
MAX_LINE_LENGTH 🔒
Maximum line length to prevent line-based denial of service

Functions§

ApplyDeltaChanges 🔒
Applies delta changes to the document text and returns the updated lines.
CMP_Range_Position 🔒
Compares two RPC ranges to determine their order in the document. Returns negative if a comes before b, zero if equal, positive if a comes after b.
PositionToOffset 🔒
Converts line/column position to byte offset in text.