Skip to content
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

Use char index rather than position for indent slice #11645

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

A beginner's mistake :)

Closes #11641.

@charliermarsh charliermarsh added the bug Something isn't working label May 31, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) May 31, 2024 19:01
@charliermarsh charliermarsh merged commit f9a6450 into main May 31, 2024
15 checks passed
@charliermarsh charliermarsh deleted the charlie/pos branch May 31, 2024 19:04
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@@ -106,7 +106,13 @@ fn detect_indention(tokens: &[LexResult], locator: &Locator) -> Indentation {
}
TokenKind::NonLogicalNewline => {
let line = locator.line(range.end());
let indent_index = line.chars().position(|c| !c.is_whitespace());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could do line.find(|c| !c.is_whitespace())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow TIL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule A003 cause panic
2 participants