Skip to content

Align diagnostic carets with tabs and wide Unicode characters #489

Closed

Description

@LunaStev

Reproduction

On #486 head 6fb6ed7, write a tab-indented source file (the \t below must be an actual tab):

from pathlib import Path
Path('/tmp/tab-caret.wave').write_text('fun main() {\n\tmissing;\n}\n')

Then run:

target/release/wavec check /tmp/tab-caret.wave

The compiler correctly reports :2:2 in Unicode scalar coordinates. The source row contains a literal tab, but the caret row uses one ordinary space, so the underline appears before the identifier in a terminal. A second reproducer is:

fun main() {
    var 이름: i32 = 1; 이름; missing;
}

Its stored scalar column is correctly 26, but the preceding Korean characters occupy two terminal cells each and the underline is visually displaced.

Cause and scope

front/error/src/error.rs::display_source_block prints source lines verbatim and pads the caret with column - 1 spaces. It uses source-coordinate counts as display widths. #406/#486 fix which source occurrence is selected; this follow-up concerns terminal rendering only.

Acceptance

  • Compute caret display offsets from the actual source prefix, including tabs and wide characters, with a documented tab policy.
  • Apply the same rule to full-source and single-line diagnostic rendering.
  • Add focused output tests for a tab-indented error, wide characters before an error and ordinary ASCII.
  • Preserve UTF-8 byte spans and one-based Unicode scalar coordinates in JSON; do not convert the machine-readable location contract to terminal cells.
  • Keep the underline immediately after the failing source row.

Start with front/error/src/error.rs and tests/frontend_regressions.rs. Related documentation task #404 remains separate.

Activity

  1. added
    bug
    help wanted
    ui/ux
    on Sep 7, 2026
  2. self-assigned this
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wantedui/ux

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions