You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 'Content-Length' value returned by TSServer does not take into account that newlines on Windows are two characters \r\n instead of \n. The issue was found in PR ycm-core/ycmd#156.
Here's a minimal example. Create a dummy test.ts file and a Python script with the following lines:
In all these cases, TSServer returns a length of 78 characters ({"seq":0,"type":"response","command":"reload","request_seq":0,"success":true} is 77 long). It should return a length of 79 characters on Windows.
The text was updated successfully, but these errors were encountered:
Alternatively sendLineToClient should either \n or \r\n on both platforms. Since this is an HTTP-like protocol I suggest CRLF for consistency.
In any case I suggest it would be better to send byte-for-byte the same output on all platforms.
(Some background for those not familiar:
HTTP and the web generally favour CRLF (it's specified in the MIME standard and also the format of multiline textboxes in web forms).
OTOH Linux and XML generally favour LF alone.
It's specified for XML which doesn't even have an option to preserve CR, even though this means there is effectively no such thing as MIME type text/xml (CR is required in text/* and effectively forbidden in XML).
And in Linux it's effectively forbidden as well (e.g. bash and many other tools will choke on CR as it isn't recognised as harmless whitespace by system() so if it appears on the end of a script line it will be tacked on to the last argument, generally resulting in some sort of failure).
[READY] Improve newline TypeScript fix on Windows
This change was suggested by @puremourning in PR puremourning#1.
With this change, we have nothing to do if issue microsoft/TypeScript#3403 is fixed and we will still support TSServer versions without the fix.
Also, according to this comment in the code:
> The response message is a JSON object which comes back on one line. Since this might change in the future, we use the 'Content-Length' header.
we should use `read` instead of `readline`.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/503)
<!-- Reviewable:end -->
The 'Content-Length' value returned by TSServer does not take into account that newlines on Windows are two characters
\r\n
instead of\n
. The issue was found in PR ycm-core/ycmd#156.Here's a minimal example. Create a dummy
test.ts
file and a Python script with the following lines:This script sends requests to TSServer and tries to read them. An exception is raised if no
Content-Length
key in header is found.On Linux, the output is:
On Windows:
If
contentlength
is incremented by one:In all these cases, TSServer returns a length of 78 characters (
{"seq":0,"type":"response","command":"reload","request_seq":0,"success":true}
is 77 long). It should return a length of 79 characters on Windows.The text was updated successfully, but these errors were encountered: