Skip to content

Wrong outer padding #352

Description

@abs0luty

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions