Fix compiling empty file

This commit is contained in:
James Westman 2022-06-17 11:10:43 -05:00
parent 7eb0c1ae0d
commit c094743e84
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 3 additions and 1 deletions

View file

@ -68,7 +68,7 @@ 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]:
if idx == 0:
if idx == 0 or len(text) == 0:
return (0, 0)
sp = text[:idx].splitlines(keepends=True)
line_num = len(sp)