Skip to content

Commit e75c6c8

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 e75c6c8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Diff for: _specifications/lsp/3.18/types/textDocumentPositionParams.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
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+
For example, some editors display the cursor as a caret at the current
12+
insertion point between characters (`A|BC`), whereas others display it
13+
as a box around the character after the insertion point (`A🄱C`).
14+
Depending on the operation, in the absence of a selection range,
15+
editors of the second kind may choose to interpret the cursor position
16+
as an implicit selection of the character _after_ the position.
617

718
```typescript
819
interface TextDocumentPositionParams {
@@ -12,8 +23,14 @@ interface TextDocumentPositionParams {
1223
textDocument: TextDocumentIdentifier;
1324

1425
/**
15-
* The position inside the text document.
26+
* The cursor position within the text document.
1627
*/
1728
position: Position;
29+
30+
/**
31+
* The selected range within the text document, if any.
32+
* The position is typically one of the endpoints of the range.
33+
*/
34+
range?: Range;
1835
}
1936
```

0 commit comments

Comments
 (0)