Handle Windows newlines
Closed this issue · 7 comments
See idris-hackers/atom-language-idris#251
I'm using idris 1.3.3 on Windows 10 here.
After the first message has been processed there is a newline char in front of the buffer, so it picks that as part of the length and only uses the first five digits to determine the length of the message, so 00004
instead of 000041
.
The atom client does this.buffer = this.buffer.trimLeft().replace(/\r\n/g, '\n')
before reading in the length.
Strictly speaking this looks like a bug in Idris, but even if I fix it there, it's probably best to handle it for robustness sake.
Idris implementation is not very robust, it adds a fudge +1
to the length for the newline (that should be +2
on windows), but then it doesn't call hPutStrLn in all cases for writing it out, at least one case has just hPutStr :-P
I'd be happy to just rip out the newlines, they're just a debugging help, it would have been best to just say that white space should be stripped. The big problem if I fix it by setting 2 as the fudge factor on windows, is that clients doing the substitution on their end will break.
Strictly speaking this looks like a bug in Idris, but even if I fix it there, it's probably best to handle it for robustness sake.
I agree, it would be nice to fix it upstream, but the client should be able to handle it for existing versions.
The fix looks simple enough. I hadn't gotten around to testing it on Windows, and this is a good impetus to do so.
Thanks for raising the issue, I'll try and get a fix up soon.
I'd be happy to just rip out the newlines
It's not just between s-exps though, they also occur within text blocks, such as in the :apropos reply.
Out of curiosity, since I've never done development (before tonight) on Windows, does your Idris source code normally contain the carriage returns? I'm wondering because I might be removing them from text that will get inserted back into the file (e.g. a :case-split reply), and I'm not sure if that will introduce inconsistencies.
@melted what's the best way to get idris1 and 2 binaries for windows?
It would be nice to set up a CI that runs all the tests on windows too
For idris 1 there are binaries for the releases here https://github.com/idris-lang/Idris-dev/wiki/Windows-Binaries
For idris 2, there are no prebuilt ones, but you can copy the github actions workflow in the Idris 2 repo.