diff --git a/jedi_language_server/jedi_utils.py b/jedi_language_server/jedi_utils.py index 80aac33..5b0f68c 100644 --- a/jedi_language_server/jedi_utils.py +++ b/jedi_language_server/jedi_utils.py @@ -308,7 +308,7 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]: until_column = ( _until_column - 1 if _until_column is not None else column + 1 ) - until_line = _until_line - 1 if _until_line is not None else line + 1 + until_line = _until_line - 1 if _until_line is not None else line if (line, column) >= (until_line, until_column): until_column, until_line = column, line diff --git a/tests/lsp_tests/test_diagnostics.py b/tests/lsp_tests/test_diagnostics.py index 8cefb5f..e80c691 100644 --- a/tests/lsp_tests/test_diagnostics.py +++ b/tests/lsp_tests/test_diagnostics.py @@ -2,6 +2,7 @@ import copy import json +import platform import tempfile from threading import Event @@ -23,7 +24,6 @@ def get_changes(changes_file): return json.load(ch_file) -@pytest.mark.skip(reason="Test broke with new compile-based diagnostics") def test_publish_diagnostics_on_open(): """Tests publish diagnostics on open.""" content_path = DIAGNOSTICS_TEST_ROOT / "diagnostics_test1_contents.txt" @@ -72,7 +72,14 @@ def _handler(params): assert len(symbols) > 0 # wait for a second to receive all notifications - done.wait(1) + done.wait(1.1) + + # Diagnostics look a little different on Windows. + filename = ( + as_uri(py_file.fullpath) + if platform.system() == "Windows" + else py_file.basename + ) expected = [ { @@ -83,9 +90,9 @@ def _handler(params): "start": {"line": 5, "character": 15}, "end": {"line": 5, "character": 16}, }, - "message": "SyntaxError: invalid syntax", + "message": f"SyntaxError: invalid syntax ({filename}, line 6)", "severity": 1, - "source": "jedi", + "source": "compile", } ], } @@ -93,7 +100,6 @@ def _handler(params): assert_that(actual, is_(expected)) -@pytest.mark.skip(reason="Test broke with new compile-based diagnostics") def test_publish_diagnostics_on_change(): """Tests publish diagnostics on change.""" @@ -175,7 +181,14 @@ def _handler(params): assert len(symbols) > 0 # wait for a second to receive all notifications - done.wait(1) + done.wait(1.1) + + # Diagnostics look a little different on Windows. + filename = ( + as_uri(py_file.fullpath) + if platform.system() == "Windows" + else py_file.basename + ) expected = [ { @@ -186,9 +199,9 @@ def _handler(params): "start": {"line": 5, "character": 15}, "end": {"line": 5, "character": 16}, }, - "message": "SyntaxError: invalid syntax", + "message": f"SyntaxError: invalid syntax ({filename}, line 6)", "severity": 1, - "source": "jedi", + "source": "compile", } ], } @@ -196,7 +209,6 @@ def _handler(params): assert_that(actual, is_(expected)) -@pytest.mark.skip(reason="Test broke with new compile-based diagnostics") def test_publish_diagnostics_on_save(): """Tests publish diagnostics on save.""" @@ -293,7 +305,14 @@ def _handler(params): ) # wait for a second to receive all notifications - done.wait(1) + done.wait(1.1) + + # Diagnostics look a little different on Windows. + filename = ( + as_uri(py_file.fullpath) + if platform.system() == "Windows" + else py_file.basename + ) expected = [ { @@ -304,9 +323,9 @@ def _handler(params): "start": {"line": 5, "character": 15}, "end": {"line": 5, "character": 16}, }, - "message": "SyntaxError: invalid syntax", + "message": f"SyntaxError: invalid syntax ({filename}, line 6)", "severity": 1, - "source": "jedi", + "source": "compile", } ], }