-
Notifications
You must be signed in to change notification settings - Fork 38
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: Remove false positive line trimming #170
Open
BurntSushi
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
BurntSushi:ag/cutting-unicode
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.
Open
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
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.
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.
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.
Previously, it was possible for a
...
to be inserted when no trimmingwas actually done. For example:
After this fix, the
...
is no longer inserted: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.