We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 154f6b1 commit ae68f90Copy full SHA for ae68f90
1 file changed
crates/ruff_linter/src/suppression.rs
@@ -501,9 +501,19 @@ impl<'a> SuppressionsBuilder<'a> {
501
indents.clear();
502
503
let (before, after) = tokens.split_at(suppression.range.start());
504
+ let mut count = 0;
505
let last_indent = before
506
.iter()
- .rfind(|token| token.kind() == TokenKind::Indent)
507
+ .filter(|token| matches!(token.kind(), TokenKind::Indent | TokenKind::Dedent))
508
+ .rfind(|token| {
509
+ // ignore matching dedents and indents above until we find
510
+ count += match token.kind() {
511
+ TokenKind::Dedent => 1,
512
+ TokenKind::Indent => -1,
513
+ _ => 0,
514
+ };
515
+ token.kind() == TokenKind::Indent && count < 0
516
+ })
517
.map(|token| self.source.slice(token))
518
.unwrap_or_default();
519
0 commit comments