Commit f386554
LSP-306 [lsp] fix line reader
When implementing readUTF8Line, it wasn't taken into account that the
`readBuffer` getter is not guaranteed to return the exact same buffer
state between accesses, even if `awaitContent` wasn't called.
The specific implementation of ByteChannel from ktor tried to fill the
buffer on access whenever it happens to be exhausted and some data was
available in the "flush" buffer.
This could lead to more data being read in the line reader loop than
expected, resulting in an invalid payload and broken framing in the LSP
protocol framing.
Now we read sequentially byte after byte. The new implementation is an
almost verbatim copy of the readUTF8LineTo method from the ktor utils.
GitOrigin-RevId: fe0cd982e94be15c6281462aa9c360d7472512dd1 parent f768344 commit f386554
File tree
1 file changed
+40
-14
lines changed- fleet/lsp.protocol/srcCommonMain/com/jetbrains/lsp/implementation
1 file changed
+40
-14
lines changedLines changed: 40 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
43 | | - | |
44 | 70 | | |
45 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
46 | 76 | | |
47 | | - | |
48 | | - | |
49 | 77 | | |
50 | | - | |
51 | 78 | | |
52 | | - | |
53 | | - | |
| 79 | + | |
54 | 80 | | |
55 | 81 | | |
56 | 82 | | |
| |||
0 commit comments