Skip to content

Commit

Permalink
fix: Return range for first line on exception in range_from_line
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejKastak committed Sep 6, 2023
1 parent 7b5dd64 commit c29d63f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yls/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def range_from_line(
"""Helper function to create a range from line index.
This function will ignore any leading/trailing whitespace."""
line_content = document.lines[line]
try:
line_content = document.lines[line]
except IndexError:
return range_for_first_line()
line_len = len(line_content)

if strip_whitespace:
Expand Down

0 comments on commit c29d63f

Please sign in to comment.