Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Tweak rendering ofsource when it's a single ASCII whitespace#169

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
BurntSushi wants to merge1 commit intorust-lang:master
base:master
Choose a base branch
Loading
fromBurntSushi:ag/handle-single-space

Conversation

@BurntSushi
Copy link
Member

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:

ifself.margin.was_cut_left(){// We have stripped some code/whitespace from the beginning, make it clear.    buffer.puts(line_offset, code_offset,"...",*lineno_color);}

Andself.margin.was_cut_left() was returning true because
computed_left was set to18446744073709551593. This kind of value
seems like a bug, although some margin values are explicitly
initialized tousize::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 otherknown regressions (including across all ofruff's test
suite), but this was mostly a result of me feeling around in the dark
here.

This PR includes a small fix (that I am not at all sure about) and aregression test that fails on current master.The input here is just a single ASCII whitespace with an annotationpointing to immediately after that whitespace. In current master, itgets 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 wascertainly confused by the output.I don't really understand the formatting code at all, but I believe theellipsis is being inserted by this code:```rustif 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 explicitlyinitialized 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 darkhere.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 8, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 8, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 8, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
@BurntSushiBurntSushi changed the titlerenderer: fix rendering ofsource when it's a single ASCII whitespacefix: Tweak rendering ofsource when it's a single ASCII whitespaceJan 8, 2025
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 9, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 10, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 13, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 14, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 14, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 15, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
BurntSushi added a commit to astral-sh/ruff that referenced this pull requestJan 15, 2025
…ourceThe change to the rendering code is elaborated on in more detail here,where I attempted to upstream it:rust-lang/annotate-snippets-rs#169Otherwise, the snapshot diff also shows a bug fix: a `^` is now renderedwhere as it previously was not.
@epage
Copy link
Contributor

The renderer was rewritten with 0.12. We should verify if this is still a problem.

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@BurntSushi@epage

[8]ページ先頭

©2009-2025 Movatter.jp