mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Use find in indent detection (#11650)
This commit is contained in:
parent
1ad5f9c038
commit
91a5fdee7a
1 changed files with 1 additions and 7 deletions
|
@ -106,13 +106,7 @@ fn detect_indention(tokens: &[LexResult], locator: &Locator) -> Indentation {
|
|||
}
|
||||
TokenKind::NonLogicalNewline => {
|
||||
let line = locator.line(range.end());
|
||||
let indent_index = line.char_indices().find_map(|(i, c)| {
|
||||
if c.is_whitespace() {
|
||||
None
|
||||
} else {
|
||||
Some(i)
|
||||
}
|
||||
});
|
||||
let indent_index = line.find(|c: char| !c.is_whitespace());
|
||||
if let Some(indent_index) = indent_index {
|
||||
if indent_index > 0 {
|
||||
let whitespace = &line[..indent_index];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue