~xerool/fennel-ls#34: 
json-rpc/read-header cuts reading the header value too much

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.

Status
REPORTED
Submitter
~noncom
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
bug

~noncom a month ago

Holy crap, I can't even edit my post. Sorry for the typos.

~xerool a month ago

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.

Register here or Log in to comment, or comment via email.