Skip to content

Caret display uses byte-based offset incorrectlyΒ #343

@davidhewitt

Description

@davidhewitt

🚩 Caret display uses byte-based columns β€” may misalign for non-ASCII on same line

With CodeLoc columns now consistently byte-based, the caret display logic in crates/monty/src/exception_public.rs:228-238 computes positions using byte offsets (line.len(), trimmed.len(), self.start.column). For lines containing multi-byte UTF-8 characters before the error location, " ".repeat(caret_start) generates ASCII spaces based on byte counts rather than display width, which can cause visual misalignment. This is a pre-existing issue (the old mixed byte/character computation was also wrong for non-ASCII) and is not introduced by this PR. Fixing it properly would require a display-width-aware calculation.

(Refers to lines 228-238)

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Originally posted by @devin-ai-integration[bot] in #342 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions