1# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2# This test verifies that we can negotiate UTF-8 offsets via protocol extension.
3{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"offsetEncoding":["utf-8","utf-16"]},"trace":"off"}}
4# CHECK: "offsetEncoding": "utf-8"
5---
6{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"/*ö*/int x;\nint y=x;"}}}
7---
8{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":6}}}
9# /*ö*/int x;
10# 01234567890
11# x is character (and utf-16) range [9,10) but byte range [10,11).
12#      CHECK:  "id": 1,
13# CHECK-NEXT:  "jsonrpc": "2.0",
14# CHECK-NEXT:  "result": [
15# CHECK-NEXT:    {
16# CHECK-NEXT:      "range": {
17# CHECK-NEXT:        "end": {
18# CHECK-NEXT:          "character": 11,
19# CHECK-NEXT:          "line": 0
20# CHECK-NEXT:        },
21# CHECK-NEXT:        "start": {
22# CHECK-NEXT:          "character": 10,
23# CHECK-NEXT:          "line": 0
24# CHECK-NEXT:        }
25# CHECK-NEXT:      },
26# CHECK-NEXT:      "uri": "file://{{.*}}/main.cpp"
27# CHECK-NEXT:    }
28# CHECK-NEXT:  ]
29---
30{"jsonrpc":"2.0","id":10000,"method":"shutdown"}
31---
32{"jsonrpc":"2.0","method":"exit"}
33