Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong outer padding #352

Open
abs0luty opened this issue Aug 15, 2023 · 0 comments
Open

Wrong outer padding #352

abs0luty opened this issue Aug 15, 2023 · 0 comments

Comments

@abs0luty
Copy link

abs0luty commented Aug 15, 2023

Bug description

Example of the bug:

error[E001]: expected `]` or `,`, found integer literal
  ┌─ test.ry:9:5
  │
7 │   fun main() {
8 │       let a = [1, 2
  │ ╭─────────────────'
9 │ │     3]
  │ │     ^ found integer literal
  │ ╰' expected `]` or `,`
10 │   }
  ^^ mismatched outer paddings

It's happening when i try to emit diagnostics with Config::after_label_lines set to 1.

Why does it happen? The bug appears to happen here and here.

Maybe you should take config.after_label_lines into account when calculating outer padding?

-            outer_padding = std::cmp::max(outer_padding, count_digits(end_line_number));
+            outer_padding = std::cmp::max(outer_padding, count_digits(end_line_number + self.config.after_label_lines));
-                    outer_padding = std::cmp::max(outer_padding, count_digits(line_number));
+                    outer_padding = std::cmp::max(outer_padding, count_digits(line_number) + self.config.end_context_lines);

And also, i don't quite get why do we need to use start_line_number here:

            outer_padding = std::cmp::max(outer_padding, count_digits(start_line_number));

I don't know much about the source code, but I hope that someone will make a pull request and fix this for both single and multi line labels.

Note

Correct me, if i misinterpreted something!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant