mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 01:20:40 +00:00
Avoid depth counting when detecting indentation (#11947)
## Summary This PR avoids the `depth` counter when detecting indentation from non-logical lines because it seems to never be used. It might have been a leftover when the logic was added originally in #11608. ## Test Plan `cargo insta test`
This commit is contained in:
parent
b617d90651
commit
a26bd01be2
1 changed files with 7 additions and 17 deletions
|
@ -97,16 +97,8 @@ fn detect_indention(tokens: &[Token], locator: &Locator) -> Indentation {
|
||||||
// cos,
|
// cos,
|
||||||
// )
|
// )
|
||||||
// ```
|
// ```
|
||||||
let mut depth = 0usize;
|
|
||||||
for token in tokens {
|
for token in tokens {
|
||||||
match token.kind() {
|
if token.kind() == TokenKind::NonLogicalNewline {
|
||||||
TokenKind::Lpar | TokenKind::Lbrace | TokenKind::Lsqb => {
|
|
||||||
depth = depth.saturating_add(1);
|
|
||||||
}
|
|
||||||
TokenKind::Rpar | TokenKind::Rbrace | TokenKind::Rsqb => {
|
|
||||||
depth = depth.saturating_sub(1);
|
|
||||||
}
|
|
||||||
TokenKind::NonLogicalNewline => {
|
|
||||||
let line = locator.line(token.end());
|
let line = locator.line(token.end());
|
||||||
let indent_index = line.find(|c: char| !c.is_whitespace());
|
let indent_index = line.find(|c: char| !c.is_whitespace());
|
||||||
if let Some(indent_index) = indent_index {
|
if let Some(indent_index) = indent_index {
|
||||||
|
@ -116,8 +108,6 @@ fn detect_indention(tokens: &[Token], locator: &Locator) -> Indentation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Indentation::default()
|
Indentation::default()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue