ocaml / ocaml-lsp

OCaml Language Server Protocol implementation
Other
760 stars 119 forks source link

Text_document.offset and Text_document.offsets #1090

Open ddickstein opened 1 year ago

ddickstein commented 1 year ago

We should be able to avoid exposing the zipper in Text_document.Expert by adding the following functions to the non-expert API:

val offset : t -> Position.t -> int
val offsets : t -> Range.t -> int * int
val position : t -> offset:int -> Position.t
val range : t -> start_offset_inclusive:int -> end_offset_exclusive:int -> Range.t

The positions should be interpreted with the text document's encoding.

ddickstein commented 1 year ago

(The latter two obviate the recently added advance function)