leona / helix-gpt

Code assistant language server for Helix with support for Copilot/OpenAI/Codeium/Ollama
MIT License
285 stars 19 forks source link

fix: Content-Lenght in the lsp.send, use the bytesize #62

Open MapoMagpie opened 2 weeks ago

MapoMagpie commented 2 weeks ago

When the completion contains non-ASCII characters, request.length actually represents the UTF-8 characters length and does not represent the correct Content-Length, whereas in Helix, the Content-Length represents the byte size of the request.

For example, "你好,世界".length is 5, but its byte size is 15,. We can use TextEncoder to convert the request to a Uint8Array and then get the length of the array, its represents the byte size of request.