Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions typescript/libs/global_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import sublime
from os.path import dirname

IS_WINDOWS = sublime.platform() == "windows"

# determine if the host is sublime text 2
IS_ST2 = int(sublime.version()) < 3000

Expand Down
9 changes: 9 additions & 0 deletions typescript/libs/node_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ def read_msg(stream, msgq, asyncReq, proc, asyncEventHandlers):
if body_length > 0:
data = stream.read(body_length)
log.debug('Read body of length: {0}'.format(body_length))

# TypeScript adds a newline at the end of the response message and counts
# it as one character (LF) towards the content length. However, newlines
# are two characters on Windows (CR LF), so we need to take care of that.
# See issue: https://github.com/Microsoft/TypeScript/issues/3403
# The fix is based on: https://github.com/ycm-core/ycmd/pull/503
if global_vars.IS_WINDOWS and data.endswith(b'\r'):
data += stream.read(1)

data_json = data.decode("utf-8")

data_dict = json_helpers.decode(data_json)
Expand Down