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: Remove false positive line trimming #170

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

Open
BurntSushi wants to merge 1 commit into rust-lang:master
base: master
Choose a base branch
Loading
from BurntSushi:ag/cutting-unicode

Conversation

Copy link
Member

@BurntSushi BurntSushi commented Jan 8, 2025

Previously, it was possible for a ... to be inserted when no trimming
was actually done. For example:

 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |

After this fix, the ... is no longer inserted:

 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "ZALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |

This is another low confidence fix where I'm not sure that it's right.
But the implementation was previously seeming to conflate the line
length (in bytes) versus the actual rendered length. So instead of
trying to do some math to figure out whether an ellipsis should be
inserted, we just keep track of whether the code line we write was
truncated or not.

Previously, it was possible for a `...` to be inserted when no trimming
was actually done. For example:
```
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
```
After this fix, the `...` is no longer inserted:
```
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "ZALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
```
This is another low confidence fix where I'm not sure that it's right.
But the implementation was previously seeming to conflate the line
length (in bytes) versus the actual rendered length. So instead of
trying to do some math to figure out whether an ellipsis should be
inserted, we just keep track of whether the code line we write was
truncated or not.
Copy link
Member Author

Hah, the ZALGO text doesn't seem to really render? The regression test in the PR should clarify things a bit.

BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 8, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 8, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 8, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 9, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 10, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 13, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 14, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 14, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 15, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
BurntSushi added a commit to astral-sh/ruff that referenced this pull request Jan 15, 2025
This fix was sent upstream and the PR description includes more details:
rust-lang/annotate-snippets-rs#170
Without this fix, there was an errant snapshot diff that looked like
this:
 |
1 | version = "0.1.0"
2 | # Ensure that the spans from toml handle utf-8 correctly
3 | authors = [
 | ___________^
4 | | { name = "Z...ALGO", email = 1 }
5 | | ]
 | |_^ RUF200
 |
That ellipsis should _not_ be inserted since the line is not actually
truncated. The handling of line length (in bytes versus actual rendered
length) wasn't quite being handled correctly in all cases.
With this fix, there's (correctly) no snapshot diff.
Copy link
Contributor

epage commented Sep 2, 2025

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

Sign up for free to 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

AltStyle によって変換されたページ (->オリジナル) /