Skip to content

Commit

Permalink
Fix off-by-one error with end column (#64)
Browse files Browse the repository at this point in the history
* fix: end offset + 1

* test: fix tests to be inclusive of last character of diagnostic
  • Loading branch information
vidhanio committed Jun 23, 2023
1 parent ea18cf0 commit 7bd1c9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _parse_output_using_regex(
end = start
if "end_line" in data and "end_column" in data:
end_line = int(data["end_line"]) - line_offset
end_column = int(data["end_column"]) - col_offset
end_column = int(data["end_column"])
if end_column == (len(line) - col_offset):
end_column = 0
end_line += 1
Expand Down
6 changes: 3 additions & 3 deletions src/test/python_tests/test_linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _log_handler(params):
{
"range": {
"start": {"line": 2, "character": 6},
"end": {"line": 2, "character": 6},
"end": {"line": 2, "character": 7},
},
"message": 'Name "x" is not defined ',
"severity": 1,
Expand Down Expand Up @@ -115,7 +115,7 @@ def _log_handler(params):
{
"range": {
"start": {"line": 2, "character": 6},
"end": {"line": 2, "character": 6},
"end": {"line": 2, "character": 7},
},
"message": 'Name "x" is not defined ',
"severity": 1,
Expand Down Expand Up @@ -237,7 +237,7 @@ def _log_handler(params):
{
"range": {
"start": {"line": 2, "character": 6},
"end": {"line": 2, "character": 6},
"end": {"line": 2, "character": 7},
},
"message": 'Name "x" is not defined ',
"severity": 2,
Expand Down

0 comments on commit 7bd1c9d

Please sign in to comment.