-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: Tweak rendering of source
when it's a single ASCII whitespace
#169
Open
BurntSushi
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
BurntSushi:ag/handle-single-space
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR includes a small fix (that I am not at all sure about) and a regression test that fails on current master. The input here is just a single ASCII whitespace with an annotation pointing to immediately after that whitespace. In current master, it gets rendered like this: ``` error: missing trailing newline at end of file | 1 | ... | ^ W292 | = help: Add trailing newline ``` But I think the insertion of an ellipsis here is not quite right. I was certainly confused by the output. I don't really understand the formatting code at all, but I believe the ellipsis is being inserted by this code: ```rust if self.margin.was_cut_left() { // We have stripped some code/whitespace from the beginning, make it clear. buffer.puts(line_offset, code_offset, "...", *lineno_color); } ``` And `self.margin.was_cut_left()` was returning true because `computed_left` was set to `18446744073709551593`. This kind of value _seems_ like a bug, although some margin values are explicitly initialized to `usize::MAX`, so maybe not. Anywho, I tried removing the condition gating the setting of `whitespace_margin`, and that seems to fix this specific case without any other _known_ regressions (including across all of `ruff`'s test suite), but this was mostly a result of me feeling around in the dark here.
BurntSushi
force-pushed
the
ag/handle-single-space
branch
from
January 8, 2025 16:41
910bfef
to
b1c4112
Compare
BurntSushi
added a commit
to astral-sh/ruff
that referenced
this pull request
Jan 8, 2025
…ource The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: rust-lang/annotate-snippets-rs#169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not.
BurntSushi
added a commit
to astral-sh/ruff
that referenced
this pull request
Jan 8, 2025
…ource The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: rust-lang/annotate-snippets-rs#169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not.
BurntSushi
added a commit
to astral-sh/ruff
that referenced
this pull request
Jan 8, 2025
…ource The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: rust-lang/annotate-snippets-rs#169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not.
BurntSushi
changed the title
renderer: fix rendering of
fix: Tweak rendering of Jan 8, 2025
source
when it's a single ASCII whitespacesource
when it's a single ASCII whitespace
BurntSushi
added a commit
to astral-sh/ruff
that referenced
this pull request
Jan 9, 2025
…ource The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: rust-lang/annotate-snippets-rs#169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not.
BurntSushi
added a commit
to astral-sh/ruff
that referenced
this pull request
Jan 10, 2025
…ource The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: rust-lang/annotate-snippets-rs#169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes a small fix (that I am not at all sure about) and a
regression test that fails on current master.
The input here is just a single ASCII whitespace with an annotation
pointing to immediately after that whitespace. In current master, it
gets rendered like this:
But I think the insertion of an ellipsis here is not quite right. I was
certainly confused by the output.
I don't really understand the formatting code at all, but I believe the
ellipsis is being inserted by this code:
And
self.margin.was_cut_left()
was returning true becausecomputed_left
was set to18446744073709551593
. This kind of valueseems like a bug, although some margin values are explicitly
initialized to
usize::MAX
, so maybe not.Anywho, I tried removing the condition gating the setting of
whitespace_margin
, and that seems to fix this specific case withoutany other known regressions (including across all of
ruff
's testsuite), but this was mostly a result of me feeling around in the dark
here.