lib/theme_check/language_server/server.rb in theme-check-1.1.0 vs lib/theme_check/language_server/server.rb in theme-check-1.2.0

- old
+ new

@@ -50,11 +50,22 @@ def send_response(response) response_body = JSON.dump(response) log(JSON.pretty_generate(response)) if $DEBUG - @out.write("Content-Length: #{response_body.bytesize}\r\n") - @out.write("\r\n") + # Because programming is fun, + # + # Ruby on Windows turns \n into \r\n. Which means that \r\n + # gets turned into \r\r\n. Which means that the protocol + # breaks on windows unless we turn STDOUT into binary mode and + # set the encoding manually (yuk!) or we do this little hack + # here and put \n which gets transformed into \r\n on windows + # only... + # + # Hours wasted: 8. + eol = Gem.win_platform? ? "\n" : "\r\n" + @out.write("Content-Length: #{response_body.bytesize}#{eol}") + @out.write(eol) @out.write(response_body) @out.flush end def log(message)