I found that the upper limit of substringing at https://git.sr.ht/~xerool/fennel-ls/tree/main/item/src/fennel-ls/json-rpc.fnl#L23 cuts off one character of the content size number, so that, for example this:
Content-Length: 2382
yields number 238
, and not 2382
, and the subsequent communication gets ruined.
In the original code cited below the upper cut is done at -2
characters, which, as far as I understand, implies cutting of 2 characters, even though the comment says about trimming off the \r
.
I have replaced this with a regexed trim, just to be on the safe side, using this instead of the original code:
v (string.sub header-line (+ sep 2))
v (string.gsub v "[ \t]+%f[\r\n%z]" "")
and it resolved the problem, so that the LS started actually seting the real message that was coming.
Not sure if it's somehow related to the environment, I'm on Windows 10, Emacs 29.4, trying out fennel-ls via M-x eglot
.
Holy crap, I can't even edit my post. Sorry for the typos.
Good catch! I think I see what's going on here. Lua is weird, in that -2 does actually mean to trim one character, but it turns out that no trimming is necessary on windows systems.