From e75c6c88bc76cec6ac9acc714bd6e530f23ebd6e Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Sun, 22 Sep 2024 17:11:13 -0400 Subject: [PATCH] textDocumentPositionParams: add optional range This change adds an optional range field to textDocumentPositionParams so that clients can, for example, query a subexpression such as x.f within a larger expression g(x.f[i]). Also, clarify the text about cursor bias. Fixes #377 Fixes #1029 --- .../3.18/types/textDocumentPositionParams.md | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/_specifications/lsp/3.18/types/textDocumentPositionParams.md b/_specifications/lsp/3.18/types/textDocumentPositionParams.md index b3e434afe..a5342109e 100644 --- a/_specifications/lsp/3.18/types/textDocumentPositionParams.md +++ b/_specifications/lsp/3.18/types/textDocumentPositionParams.md @@ -2,7 +2,18 @@ Was `TextDocumentPosition` in 1.0 with inlined parameters. -A parameter literal used in requests to pass a text document and a position inside that document. It is up to the client to decide how a selection is converted into a position when issuing a request for a text document. The client can, for example, honor or ignore the selection direction to make LSP request consistent with features implemented internally. +A parameter literal used in requests to pass a text document and a +position or optional range within that document. + +To be consistent with features implemented internally, the client is +free to choose for each LSP request how a cursor position or text +selection is converted into a position or range. +For example, some editors display the cursor as a caret at the current +insertion point between characters (`A|BC`), whereas others display it +as a box around the character after the insertion point (`A🄱C`). +Depending on the operation, in the absence of a selection range, +editors of the second kind may choose to interpret the cursor position +as an implicit selection of the character _after_ the position. ```typescript interface TextDocumentPositionParams { @@ -12,8 +23,14 @@ interface TextDocumentPositionParams { textDocument: TextDocumentIdentifier; /** - * The position inside the text document. + * The cursor position within the text document. */ position: Position; + + /** + * The selected range within the text document, if any. + * The position is typically one of the endpoints of the range. + */ + range?: Range; } ```