dart-lang / dart-pad

An online Dart editor with support for console, web, and Flutter apps
https://dartpad.dev
BSD 3-Clause "New" or "Revised" License
1.71k stars 555 forks source link

Error output should use monospace font #2933

Open lrhn opened 6 months ago

lrhn commented 6 months ago

The error output from the compiler is displayed in a proportional font. Since it contains lines with "^"s that point into the prior line, based on character count, the position of that ^ is not correct when viewed using a proportional font, and important in information is lost or misleading.. Compare:

main.dart:20:20: Error: Property 'y' cannot be accessed on '({int x, int y})?' because it is potentially null. Try accessing using ?. instead.     print((a!.x, a.y, n3: 0)); // ERR                    ^

with

main.dart:20:20: Error: Property 'y' cannot be accessed on '({int x, int y})?' because it is potentially null.
Try accessing using ?. instead.
    print((a!.x, a.y, n3: 0)); // ERR
                   ^

In the latter, it's possible to see that the ^ is on the y. In the former, probably depending on font, OS and scaling, it seems like the ^ points nearer to the , after x, which is not where the error is.

To reproduce, use fx:

final ({int x, int y})? a = null;
void main() {
  print((a!.x, a.y, n3: 0)); // ERR
}

and try to run it. The compiler error output (bottom right) is shown in proportional font, and shows an ^ pointing near the x, not at the y as it should.

Karelaking commented 5 months ago

can you explain this properly. and add some images and examples

lrhn commented 5 months ago

Have expanded on the description, and added an example that reproduces the issue.

The examples already show the problem of displaying output intended for fixed-width fonts in a proportional font.

lrhn commented 2 months ago

Hasn't landed yet. Font is still proportional. (Linux desktop.)