diff --git a/pyright_to_rdjson/pyright_to_rdjson.py b/pyright_to_rdjson/pyright_to_rdjson.py index a0c8cb3..ac0ebe4 100755 --- a/pyright_to_rdjson/pyright_to_rdjson.py +++ b/pyright_to_rdjson/pyright_to_rdjson.py @@ -33,12 +33,13 @@ def pyright_to_rdjson(jsonin: TextIO): "path": d["file"], "range": { "start": { - "line": d["range"]["start"]["line"], - "column": d["range"]["start"]["character"], + # pyright uses zero-based offsets + "line": d["range"]["start"]["line"] + 1, + "column": d["range"]["start"]["character"] + 1, }, "end": { - "line": d["range"]["end"]["line"], - "column": d["range"]["end"]["character"], + "line": d["range"]["end"]["line"] + 1, + "column": d["range"]["end"]["character"] + 1, }, }, }, diff --git a/pyright_to_rdjson/tests/test_pyright_to_rdjson.py b/pyright_to_rdjson/tests/test_pyright_to_rdjson.py index 02b32e2..18cb9b4 100755 --- a/pyright_to_rdjson/tests/test_pyright_to_rdjson.py +++ b/pyright_to_rdjson/tests/test_pyright_to_rdjson.py @@ -43,8 +43,9 @@ def test_pyright_to_rdjson(self): pyright_line_start = pyright_line_range["start"] pyright_line_end = pyright_line_range["end"] - assert rdjson_line_start["line"] == pyright_line_start["line"] - assert rdjson_line_start["column"] == pyright_line_start["character"] + # pyrights offsets are zero-based + assert rdjson_line_start["line"] == pyright_line_start["line"] + 1 + assert rdjson_line_start["column"] == pyright_line_start["character"] + 1 - assert rdjson_line_end["line"] == pyright_line_end["line"] - assert rdjson_line_end["column"] == pyright_line_end["character"] + assert rdjson_line_end["line"] == pyright_line_end["line"] + 1 + assert rdjson_line_end["column"] == pyright_line_end["character"] + 1