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
Related to #12130, it turns out that computing the line width on a char-by-char basis and as a whole str is different. From the docs of unicode-width, it's these cases where it differs specifically.
In the linter, the LineWidthBuilder determines the width by looking at each char individually. But, in some places the width is computed directly on &str which creates the panic as in #12130. These cases are:
## Summary
This PR updates various references in the linter to compute the
line-width for summing the width of each `char` in a `str` instead of
computing the width of the `str` itself.
Refer to #12133 for more details.
fixes: #12130
## Test Plan
Add a file with null (`\0`) character which is zero-width. Run this test
case on `main` to make sure it panics and switch over to this branch to
make sure it doesn't panic now.
Related to #12130, it turns out that computing the line width on a char-by-char basis and as a whole
str
is different. From the docs ofunicode-width
, it's these cases where it differs specifically.In the linter, the
LineWidthBuilder
determines the width by looking at eachchar
individually. But, in some places the width is computed directly on&str
which creates the panic as in #12130. These cases are:ruff/crates/ruff_linter/src/rules/pycodestyle/overlong.rs
Line 64 in eeb24b1
ruff/crates/ruff_linter/src/rules/isort/sorting.rs
Line 109 in eeb24b1
ruff/crates/ruff_linter/src/rules/isort/sorting.rs
Line 160 in eeb24b1
ruff/crates/ruff_linter/src/fix/snippet.rs
Lines 35 to 39 in eeb24b1
In the formatter,
ruff/crates/ruff_formatter/src/printer/mod.rs
Lines 845 to 846 in eeb24b1
ruff/crates/ruff_formatter/src/printer/mod.rs
Lines 1520 to 1522 in eeb24b1
The text was updated successfully, but these errors were encountered: