Skip to content

Commit

Permalink
fix: accurate error underline for tab freaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Oct 8, 2022
1 parent 1297c18 commit 8f1064d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mecha/utils.py
Expand Up @@ -24,6 +24,8 @@

WHITESPACE_REGEX = re.compile(r"\s+")

NOTABS_REGEX = re.compile(r"[^\t]")


def normalize_whitespace(op: str) -> str:
"""Replace whitespace with underscores."""
Expand Down Expand Up @@ -171,7 +173,7 @@ def underline_code(
stop = min(stop, len(code.rstrip()) + 1)

if start < stop:
underline = " " * (start - 1) + "^" * (stop - start)
underline = NOTABS_REGEX.sub(" ", code[: start - 1]) + "^" * (stop - start)
view.insert(index + 1, underline)
gutter.insert(index + 1, ":")

Expand Down

0 comments on commit 8f1064d

Please sign in to comment.