mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +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 => {
|
TokenKind::NonLogicalNewline => {
|
||||||
let line = locator.line(range.end());
|
let line = locator.line(range.end());
|
||||||
let indent_index = line.char_indices().find_map(|(i, c)| {
|
let indent_index = line.find(|c: char| !c.is_whitespace());
|
||||||
if c.is_whitespace() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(i)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if let Some(indent_index) = indent_index {
|
if let Some(indent_index) = indent_index {
|
||||||
if indent_index > 0 {
|
if indent_index > 0 {
|
||||||
let whitespace = &line[..indent_index];
|
let whitespace = &line[..indent_index];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue