This PR adds support for the `positionEncoding` client capability introduced in LSP 3.17. Clangd can now negotiate the position encoding with the client during initialization. Fix https://github.com/clangd/clangd/issues/1746 Co-authored-by: kadir çetinkaya <kadircetinkaya.06.tr@gmail.com>
33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
|
|
# This test verifies that we can negotiate UTF-8 offsets via the positionEncodings capability introduced in LSP 3.17.
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"general":{"positionEncodings":["utf-8","utf-16"]}},"trace":"off"}}
|
|
# CHECK: "positionEncoding": "utf-8"
|
|
---
|
|
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"/*ö*/int x;\nint y=x;"}}}
|
|
---
|
|
{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":6}}}
|
|
# /*ö*/int x;
|
|
# 01234567890
|
|
# x is character (and utf-16) range [9,10) but byte range [10,11).
|
|
# CHECK: "id": 1,
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
# CHECK-NEXT: "result": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 11,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 10,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "uri": "file://{{.*}}/main.cpp"
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ]
|
|
---
|
|
{"jsonrpc":"2.0","id":10000,"method":"shutdown"}
|
|
---
|
|
{"jsonrpc":"2.0","method":"exit"}
|