Skip to content

Adjust pbox's margin based on length of prefix - #97

Merged
johnyob merged 2 commits into
johnyob:mainfrom
WardBrian:pbox-adjust-margin-for-prefix
Aug 5, 2026
Merged

Adjust pbox's margin based on length of prefix#97
johnyob merged 2 commits into
johnyob:mainfrom
WardBrian:pbox-adjust-margin-for-prefix

Conversation

@WardBrian

Copy link
Copy Markdown
Contributor

Building on #96, this is a partial fix for #94.

The margin for pboxes is adjusted down based on the length of the prefix, meaning that text wraps in more expected ways when at the end of a long line.

It would, of course, be nice to also truncate the source line, which would also probably remove the need for the manual minimum width of 25.

Compare the test in this PR:

    error: cannot find value `missing` in this scope
        ┌─ foo.rs:2:140
      2 │    println!("What happens when I have an error at a really high column? Let's find out by trying to print something that doesn't exist {}", missing);
        │                                                                                                                                             ^^^^^^^ not found in this scope.
        │                                                                                                                                                      did you mean 'missingo'?

with rustc:

error[E0425]: cannot find value `missing` in this scope
 --> foo.rs:3:140
  |
3 | ...g that doesn't exist {}", missing);
  |                              ^^^^^^^ not found in this scope

@WardBrian

WardBrian commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

There also might be an off-by-one somewhere, because I'm not sure why did you mean has one extra space to start out

Fixed by #98

@WardBrian
WardBrian force-pushed the pbox-adjust-margin-for-prefix branch from 83cc40c to 4e7f32e Compare August 5, 2026 14:48

@johnyob johnyob left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lgtm 🚀

Thank you for your contribution 🙏

@johnyob
johnyob merged commit b40f942 into johnyob:main Aug 5, 2026
7 checks passed
@WardBrian
WardBrian deleted the pbox-adjust-margin-for-prefix branch August 5, 2026 15:27
shonfeder pushed a commit to ocaml/opam-repository that referenced this pull request Aug 6, 2026
CHANGES:

- fix(renderer): adjust margin for messages near end of line ([johnyob/grace#97](johnyob/grace#97))
- fix(renderer): remove extra space in trailing labels ([johnyob/grace#98](johnyob/grace#98))
- fix(renderer): error recovery on invalid UTF-8 strings ([johnyob/grace#99](johnyob/grace#99))
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.

2 participants