Skip to content

Commit 37abb8c

Browse files
committed
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
1 parent 0046ca2 commit 37abb8c

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

_specifications/lsp/3.18/types/textDocumentPositionParams.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22

33
Was `TextDocumentPosition` in 1.0 with inlined parameters.
44

5-
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.
5+
A parameter literal used in requests to pass a text document and a
6+
position or optional range within that document.
7+
8+
To be consistent with features implemented internally, the client is
9+
free to choose for each LSP request how a cursor position or text
10+
selection is converted into a position or range.
11+
12+
For example, some editors display the cursor as a caret at the current
13+
insertion point between characters (`A|BC`), whereas others display it
14+
as a box around the character after the insertion point (`A🄱C`).
15+
16+
Depending on the operation, in the absence of a selection range,
17+
editors of the second kind may choose to interpret the cursor position
18+
as an implicit selection the character after the position.
619

720
```typescript
821
interface TextDocumentPositionParams {
@@ -12,8 +25,14 @@ interface TextDocumentPositionParams {
1225
textDocument: TextDocumentIdentifier;
1326

1427
/**
15-
* The position inside the text document.
28+
* The cursor position within the text document.
1629
*/
1730
position: Position;
31+
32+
/**
33+
* The selected range within the text document, if any.
34+
* The position is typically one of the endpoints of the range.
35+
*/
36+
range?: Range;
1837
}
1938
```

0 commit comments

Comments
 (0)