diff --git a/anakinls/server.py b/anakinls/server.py index 0f6419b..989d051 100644 --- a/anakinls/server.py +++ b/anakinls/server.py @@ -396,7 +396,9 @@ def _validate(ls: LanguageServer, uri: str, script: Script = None): codestyleopts = get_pycodestyle_options(ls, uri) CodestyleChecker( script.path, - script._code.splitlines(True), + script._code.replace('\r\n', '\n') + .replace('\r', '\n') + .splitlines(True), codestyleopts, CodestyleReport(codestyleopts, result), ).check_all() diff --git a/tests/test_server.py b/tests/test_server.py index 38c3203..ccb4c02 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -151,3 +151,14 @@ def test_only_jedi_syntax_error_diagnostic(server, content): diagnostics = server.publish_diagnostics.call_args[0][1] assert len(diagnostics) == 1 assert diagnostics[0].source == 'jedi' + + +def test_pycodestyle_lineending(server): + uri = 'file://test_pycodestyle.py' + doc = Document(uri, 'while True:\r\n break\r\n') + server.workspace.get_text_document = Mock(return_value=doc) + server.publish_diagnostics = Mock() + aserver._validate(server, uri) + assert server.publish_diagnostics.called + diagnostics = server.publish_diagnostics.call_args[0][1] + assert len(diagnostics) == 0