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

Improve single line label rendering #241

Merged
merged 4 commits into from May 18, 2020
Merged

Conversation

brendanzab
Copy link
Owner

@brendanzab brendanzab commented May 14, 2020

This makes the rendering of carets smarter when there are multiple labels on the same line. Instead of this:

   ┌─ one_line.rs:3:5
   │
 3 │     v.push(v.pop().unwrap());
   │     - first borrow later used by call
   │       ---- first mutable borrow occurs here
   │            ^ second mutable borrow occurs here
   │

...we now render the following:

   ┌─ one_line.rs:3:5
   │
 3 │     v.push(v.pop().unwrap());
   │     - ---- ^ second mutable borrow occurs here
   │     │ │
   │     │ first mutable borrow occurs here
   │     first borrow later used by call
   │

Resolves #211.

@brendanzab brendanzab force-pushed the single-line-label-rendering branch 6 times, most recently from 78ca5d4 to 05ad84a Compare May 15, 2020 06:13
@brendanzab brendanzab force-pushed the single-line-label-rendering branch 6 times, most recently from dfe8330 to 2ab3679 Compare May 18, 2020 01:16
@brendanzab brendanzab marked this pull request as ready for review May 18, 2020 01:16
@brendanzab brendanzab force-pushed the single-line-label-rendering branch 2 times, most recently from 7df8674 to 49672eb Compare May 18, 2020 01:37
@brendanzab
Copy link
Owner Author

Ok, this should be ready for review!

│ ^
│ │
│ Unexpected '{'
│ Expected '('
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should ultimately address one of the main complaints described in #231 by @tnowacki. cc. diem/diem#3447

@brendanzab
Copy link
Owner Author

brendanzab commented May 18, 2020

Note that this still does not cover the case where single line labels overlap multiline labels. Multiline labels will still be rendered below single line labels, eg.

40 │ │   Fruitcake jelly-o danish toffee. Tootsie roll pastry cheesecake
41 │ │   soufflé marzipan. Chocolate bar oat cake jujubes lollipop pastry
42 │ │   cupcake. Candy canes cupcake toffee gingerbread candy canes muffin
   │ │                  ------------- ^^^^^^^^^^^^^^^^^^ blah blah
   │ ╰──────────^ blah blah

I still think this is a much needed improvement, however!

@brendanzab brendanzab force-pushed the single-line-label-rendering branch from 49672eb to 664d27e Compare May 18, 2020 05:06
This makes the rendering of carets smarter when there are multiple labels on the same line. Instead of this:

```
   ┌─ one_line.rs:3:5
   │
 3 │     v.push(v.pop().unwrap());
   │     - first borrow later used by call
   │       ---- first mutable borrow occurs here
   │            ^ second mutable borrow occurs here
   │
```
...we now render the following:
```
   ┌─ one_line.rs:3:5
   │
 3 │     v.push(v.pop().unwrap());
   │     - ---- ^ second mutable borrow occurs here
   │     │ │
   │     │ first mutable borrow occurs here
   │     first borrow later used by call
   │
```
@brendanzab brendanzab force-pushed the single-line-label-rendering branch from a9ed983 to 1580d08 Compare May 18, 2020 05:22
@brendanzab brendanzab merged commit dbc5d0b into master May 18, 2020
@brendanzab brendanzab deleted the single-line-label-rendering branch May 18, 2020 05:49
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

Successfully merging this pull request may close these issues.

Make single-line label rendering clearer
2 participants