- Notifications
You must be signed in to change notification settings - Fork47
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 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:masterChoose a base branch fromBurntSushi: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.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or 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 trimmingwas actually done. For example:``` |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | 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 correctly3 | 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 linelength (in bytes) versus the actual rendered length. So instead oftrying to do some math to figure out whether an ellipsis should beinserted, we just keep track of whether the code line we write wastruncated or not.MemberAuthor
BurntSushi commentedJan 8, 2025
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 requestJan 8, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 8, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 8, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 9, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 10, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 13, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 14, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 14, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 15, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) 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 requestJan 15, 2025
This fix was sent upstream and the PR description includes more details:rust-lang/annotate-snippets-rs#170Without this fix, there was an errant snapshot diff that looked likethis: |1 | version = "0.1.0"2 | # Ensure that the spans from toml handle utf-8 correctly3 | authors = [ | ___________^4 | | { name = "Z...ALGO", email = 1 }5 | | ] | |_^ RUF200 |That ellipsis should _not_ be inserted since the line is not actuallytruncated. The handling of line length (in bytes versus actual renderedlength) wasn't quite being handled correctly in all cases.With this fix, there's (correctly) no snapshot diff.
Contributor
epage commentedSep 2, 2025
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
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.