Skip to content

Commit f794a95

Browse files
committed
basic: update Position documentation
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 57d9346 commit f794a95

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

basic.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,24 @@ var EOL = []string{"\n", "\r\n", "\r"}
2828

2929
// Position represents a text document expressed as zero-based line and zero-based character offset.
3030
//
31+
// The offsets are based on a UTF-16 string representation.
32+
// So a string of the form "a𐐀b" the character offset of the character "a" is 0,
33+
// the character offset of "𐐀" is 1 and the character offset of "b" is 3 since 𐐀 is represented using two code units in UTF-16.
34+
//
35+
// To ensure that both client and server split the string into the same line representation the protocol
36+
// specifies the following end-of-line sequences: "\n", "\r\n' and "\r".
37+
//
3138
// A position is between two characters like an "insert" cursor in a editor.
39+
// Special values like for example "-1" to denote the end of a line are not supported.
3240
type Position struct {
3341
// Line position in a document (zero-based).
3442
Line uint32 `json:"line"`
3543

36-
// Character offset on a line in a document (zero-based). Assuming that the line is
37-
// represented as a string, the `character` value represents the gap between the
38-
// `character` and `character + 1`.
44+
// Character offset on a line in a document (zero-based).
45+
//
46+
// Assuming that the line is represented as a string, the "character" value represents the gap between the
47+
// "character" and "character + 1".
48+
//
3949
// If the character value is greater than the line length it defaults back to the
4050
// line length.
4151
Character uint32 `json:"character"`

0 commit comments

Comments
 (0)