~/bend-docscommunity

src/lsp/enc.bend checks

raw source on the hub · import 0xd96f2ab40f5df4925c42e96d0ba857ff/src/lsp/enc.bend as Enc

lsp/enc: position encodings (LSP 3.17 positionEncoding), the one place a character offset crosses the protocol boundary. Pure. bolt counts columns in code points (a Bend String is a list of them); a client that offers utf-32 gets exactly those, and any other gets UTF-16 code units, where a char outside the Basic Multilingual Plane counts 2. Every position the server reads goes through into, and every one it sends through out (proto.bend's position, semantic.bend's tokens).

3 imports
import Base
import 0x81c67699424929b5c44cd8577e18117f/main.bend as Ezjson
import 0x81c67699424929b5c44cd8577e18117f/src/value.bend as J

Types

type Enc source · line 13 · raw

Data

the encodings the server speaks

type Cols source · line 122 · raw

Data

a document as the boundary sees it: the encoding and the text's lines

Definitions

def name source · line 18 · raw

@ee:Enc -> String

an encoding's name on the wire

def offers source · line 27 · raw

@cells:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> Bool

does a list of encodings (JSON cells) offer utf-32? A cell that is not a string offers nothing

def cells source · line 36 · raw

@jj:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> 0x81c67699424929b5c44cd8577e18117f/src/value.Json

the cells of an array, JNil when it is not one

def chosen source · line 44 · raw

@yes:Bool -> Enc

the encoding for utf-32 offered or not

def negotiate source · line 53 · raw

@params:0x81c67699424929b5c44cd8577e18117f/src/value.Json -> Enc

the encoding initialize settles on: utf-32 when the client's general.positionEncodings offers it, else UTF-16, LSP's default

def wide source · line 60 · raw

@cc:Char -> Bool

does a char take two UTF-16 code units (it lies past U+FFFF)?

def units.step source · line 64 · raw

@isw:Bool -> @rest:Nat -> Nat

the units a char and the ones after it take: two for a wide char, else one

def units source · line 73 · raw

@cs:List<&2, Char> -> @nn:Nat -> Nat

the UTF-16 code units the first n chars of a line take; a column past the line's end counts one unit a column

def points.skip source · line 84 · raw

@isw:Bool -> @pp:Nat -> Nat

the units left after a char, from 1+p units: p after a narrow one, one fewer after a wide one (none when the offset falls inside its pair)

def points source · line 96 · raw

@cs:List<&2, Char> -> @uu:Nat -> Nat

the chars the first u UTF-16 code units of a line cover; an offset inside a pair covers its char, and one past the line's end counts one column a unit

def out.of source · line 106 · raw

@ee:Enc -> @cs:List<&2, Char> -> @nn:Nat -> Nat

a code-point column of a line in an encoding

def into.of source · line 114 · raw

@ee:Enc -> @cs:List<&2, Char> -> @uu:Nat -> Nat

an encoding's column of a line as a code-point column

def cols source · line 126 · raw

@ee:Enc -> @text:String -> Cols

a document's text under an encoding

def chars source · line 130 · raw

@lines:List<&2, String> -> @line:U32 -> List<&2, Char>

a line's chars, none past the end

def out.col source · line 134 · raw

@ee:Enc -> @cs:List<&2, Char> -> @col:U32 -> U32

a code-point column of a line's chars, sent in an encoding

def out source · line 142 · raw

@cc:Cols -> @line:U32 -> @col:U32 -> U32

a code-point column sent in the negotiated encoding

def into.col source · line 147 · raw

@ee:Enc -> @cs:List<&2, Char> -> @col:U32 -> U32

a column of a line's chars read in an encoding, as a code-point column

def into source · line 155 · raw

@cc:Cols -> @line:U32 -> @col:U32 -> U32

a column read in the negotiated encoding, as a code-point column