Skip to content

Location excerpts miscompute character positions for unicode and greedy ranges #12806

@benodiwal

Description

@benodiwal

Problem

There are two issues with how error locations are displayed:

1. Greedy version_loc

The version location captures the closing parenthesis when it shouldn't.

Example:
File "dune-project", line 1, characters 11-13:
(lang dune è)

Should be characters 11-12 (just è), not 11-13 (which includes the ))

2. Unicode length miscalculation for East Asian characters

East Asian characters are double-width in terminals, but the underline calculation doesn't account for this.

Example:
File "dune-project", line 1, characters 11-21:
(lang dune 中3.16文)

The string 中3.16文 is 6 characters but shows 10 carets because and are double-width.

Related

This was observed while working on #12794

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