You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 file name to clipboardExpand all lines: tests/formatter.rs
+30
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,36 @@ use annotate_snippets::{Level, Renderer, Snippet};
2
2
3
3
use snapbox::{assert_data_eq, str};
4
4
5
+
// This tests that an ellipsis is not inserted into Unicode text when a line
6
+
// wasn't actually trimmed.
7
+
//
8
+
// This is a regression test where `...` was inserted because the code wasn't
9
+
// properly accounting for the *rendered* length versus the length in bytes in
10
+
// all cases.
11
+
#[test]
12
+
fnunicode_cut_handling(){
13
+
let source = "version = \"0.1.0\"\n# Ensure that the spans from toml handle utf-8 correctly\nauthors = [\n { name = \"Z\u{351}\u{36b}\u{343}\u{36a}\u{302}\u{36b}\u{33d}\u{34f}\u{334}\u{319}\u{324}\u{31e}\u{349}\u{35a}\u{32f}\u{31e}\u{320}\u{34d}A\u{36b}\u{357}\u{334}\u{362}\u{335}\u{31c}\u{330}\u{354}L\u{368}\u{367}\u{369}\u{358}\u{320}G\u{311}\u{357}\u{30e}\u{305}\u{35b}\u{341}\u{334}\u{33b}\u{348}\u{34d}\u{354}\u{339}O\u{342}\u{30c}\u{30c}\u{358}\u{328}\u{335}\u{339}\u{33b}\u{31d}\u{333}\", email = 1 }\n]\n";
0 commit comments