mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix diagnostic location reporting
Text positions at the beginning of a line were being shown on the previous line.
This commit is contained in:
parent
40f493b378
commit
7ef314ff94
2 changed files with 3 additions and 4 deletions
|
@ -74,9 +74,8 @@ def did_you_mean(word: str, options: T.List[str]) -> T.Optional[str]:
|
||||||
def idx_to_pos(idx: int, text: str) -> T.Tuple[int, int]:
|
def idx_to_pos(idx: int, text: str) -> T.Tuple[int, int]:
|
||||||
if idx == 0 or len(text) == 0:
|
if idx == 0 or len(text) == 0:
|
||||||
return (0, 0)
|
return (0, 0)
|
||||||
sp = text[:idx].splitlines(keepends=True)
|
line_num = text.count("\n", 0, idx) + 1
|
||||||
line_num = len(sp)
|
col_num = idx - text.rfind("\n", 0, idx) - 1
|
||||||
col_num = len(sp[-1])
|
|
||||||
return (line_num - 1, col_num)
|
return (line_num - 1, col_num)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1,10,0,Expected a version number for GTK
|
1,11,0,Expected a version number for GTK
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue