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

fix(analyzer): suppression comment fails with inner comments in functions #4643

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ where
/// signals that start after this position in the file will be skipped
fn flush_matches(&mut self, cutoff: Option<TextSize>) -> ControlFlow<Break> {
while let Some(entry) = self.signal_queue.peek() {
let start = entry.text_range.start();
let entry_start = entry.text_range.start();
if let Some(cutoff) = cutoff {
if start >= cutoff {
if entry_start >= cutoff {
break;
}
}
Expand All @@ -384,23 +384,23 @@ where
// with a matching range
let suppression = self.line_suppressions.last_mut().filter(|suppression| {
suppression.line_index == *self.line_index
&& suppression.text_range.start() <= start
&& suppression.text_range.start() <= entry_start
});

let suppression = match suppression {
Some(suppression) => Some(suppression),
None => {
let index = self.line_suppressions.binary_search_by(|suppression| {
if suppression.text_range.end() < entry.text_range.start() {
Ordering::Less
} else if entry.text_range.end() < suppression.text_range.start() {
Ordering::Greater
} else {
Ordering::Equal
}
// text-range 0 - 92
// text-range 94 - 172
// entry 68 - 174
let index = self.line_suppressions.partition_point(|suppression| {
suppression.text_range.end() < entry.text_range.start()
});

index.ok().map(|index| &mut self.line_suppressions[index])
if index >= self.line_suppressions.len() {
None
} else {
Some(&mut self.line_suppressions[index])
}
}
};

Expand Down
Loading