Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Position comments spec conformant #1546

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions protocol/metaModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,8 @@
"method": "workspace/textDocumentContent",
"typeName": "TextDocumentContentRequest",
"result": {
"kind": "base",
"name": "string"
"kind": "reference",
"name": "TextDocumentContentResult"
},
"messageDirection": "clientToServer",
"params": {
Expand Down Expand Up @@ -4420,6 +4420,22 @@
"since": "3.18.0",
"proposed": true
},
{
"name": "TextDocumentContentResult",
"properties": [
{
"name": "text",
"type": {
"kind": "base",
"name": "string"
},
"documentation": "The text content of the text document. Please note, that the content of\nany subsequent open notifications for the text document might differ\nfrom the returned content due to whitespace and line ending\nnormalizations done on the client"
}
],
"documentation": "Result of the `workspace/textDocumentContent` request.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "TextDocumentContentRegistrationOptions",
"properties": [],
Expand Down Expand Up @@ -6876,15 +6892,15 @@
"kind": "base",
"name": "uinteger"
},
"documentation": "Line position in a document (zero-based).\n\nIf a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.\nIf a line number is negative, it defaults to 0."
"documentation": "Line position in a document (zero-based)."
},
{
"name": "character",
"type": {
"kind": "base",
"name": "uinteger"
},
"documentation": "Character offset on a line in a document (zero-based).\n\nThe meaning of this offset is determined by the negotiated\n`PositionEncodingKind`.\n\nIf the character value is greater than the line length it defaults back to the\nline length."
"documentation": "Character offset on a line in a document (zero-based).\n\nThe meaning of this offset is determined by the negotiated\n`PositionEncodingKind`."
}
],
"documentation": "Position in a text document expressed as zero-based line and character\noffset. Prior to 3.17 the offsets were always based on a UTF-16 string\nrepresentation. So a string of the form `a𐐀b` the character offset of the\ncharacter `a` is 0, the character offset of `𐐀` is 1 and the character\noffset of b is 3 since `𐐀` is represented using two code units in UTF-16.\nSince 3.17 clients and servers can agree on a different string encoding\nrepresentation (e.g. UTF-8). The client announces it's supported encoding\nvia the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).\nThe value is an array of position encodings the client supports, with\ndecreasing preference (e.g. the encoding at index `0` is the most preferred\none). To stay backwards compatible the only mandatory encoding is UTF-16\nrepresented via the string `utf-16`. The server can pick one of the\nencodings offered by the client and signals that encoding back to the\nclient via the initialize result's property\n[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value\n`utf-16` is missing from the client's capability `general.positionEncodings`\nservers can safely assume that the client supports UTF-16. If the server\nomits the position encoding in its initialize result the encoding defaults\nto the string value `utf-16`. Implementation considerations: since the\nconversion from one encoding into another requires the content of the\nfile / line the conversion is best done where the file is read which is\nusually on the server side.\n\nPositions are line end character agnostic. So you can not specify a position\nthat denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n\n@since 3.17.0 - support for negotiated position encoding.",
Expand Down Expand Up @@ -7970,12 +7986,15 @@
"name": "TextDocumentContentOptions",
"properties": [
{
"name": "scheme",
"name": "schemes",
"type": {
"kind": "base",
"name": "string"
"kind": "array",
"element": {
"kind": "base",
"name": "string"
}
},
"documentation": "The scheme for which the server provides content."
"documentation": "The schemes for which the server provides content."
}
],
"documentation": "Text document content provider options.\n\n@since 3.18.0\n@proposed",
Expand Down
6 changes: 0 additions & 6 deletions types/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ export type LSPArray = any[];
export interface Position {
/**
* Line position in a document (zero-based).
*
* If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
* If a line number is negative, it defaults to 0.
*/
line: uinteger;

Expand All @@ -134,9 +131,6 @@ export interface Position {
*
* The meaning of this offset is determined by the negotiated
* `PositionEncodingKind`.
*
* If the character value is greater than the line length it defaults back to the
* line length.
*/
character: uinteger;
}
Expand Down