Skip to content

Commit

Permalink
Adds offset '1', because pyrights offsets are zero-based (issue #25) (#…
Browse files Browse the repository at this point in the history
…26)

* Adds offset '1', because pyrights offsets are zero-based (issue #25)

* Adds offset '1', because pyrights offsets are zero-based (issue #25)

* Update pyright_to_rdjson/pyright_to_rdjson.py

Co-authored-by: Jordan Webb <[email protected]>

* Update pyright_to_rdjson/pyright_to_rdjson.py

Co-authored-by: Jordan Webb <[email protected]>

* Update pyright_to_rdjson/tests/test_pyright_to_rdjson.py

Co-authored-by: Jordan Webb <[email protected]>

* Update pyright_to_rdjson/tests/test_pyright_to_rdjson.py

Co-authored-by: Jordan Webb <[email protected]>

Co-authored-by: Jordan Webb <[email protected]>
  • Loading branch information
gersmann and jordemort authored Mar 24, 2022
1 parent 0f069d0 commit a72509b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions pyright_to_rdjson/pyright_to_rdjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down
9 changes: 5 additions & 4 deletions pyright_to_rdjson/tests/test_pyright_to_rdjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a72509b

Please sign in to comment.