From ff1d948934e1b208fb2566ba1ff4be9427e2b674 Mon Sep 17 00:00:00 2001 From: zoomdong <1344492820@qq.com> Date: Mon, 9 Dec 2024 19:27:37 +0800 Subject: [PATCH] fix(analyzer): suppression comment fails with inner comments in functions --- ..._fails_with_inner_comments_in_functions.md | 5 ++++ crates/biome_analyze/src/lib.rs | 25 +++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 .changeset/fixanalyzer_suppression_comment_fails_with_inner_comments_in_functions.md diff --git a/.changeset/fixanalyzer_suppression_comment_fails_with_inner_comments_in_functions.md b/.changeset/fixanalyzer_suppression_comment_fails_with_inner_comments_in_functions.md new file mode 100644 index 000000000000..447162a5a9b2 --- /dev/null +++ b/.changeset/fixanalyzer_suppression_comment_fails_with_inner_comments_in_functions.md @@ -0,0 +1,5 @@ +--- +biome_analyze: patch +--- + +# fix(analyzer): suppression comment fails with inner comments in functions diff --git a/crates/biome_analyze/src/lib.rs b/crates/biome_analyze/src/lib.rs index 9cfd53d5dc27..1a7ac93fb113 100644 --- a/crates/biome_analyze/src/lib.rs +++ b/crates/biome_analyze/src/lib.rs @@ -447,22 +447,15 @@ where let suppression = match suppression { Some(suppression) => Some(suppression), None => { - let index = - self.suppressions - .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 - } - }); - - index - .ok() - .map(|index| &mut self.suppressions.line_suppressions[index]) + let index = self.suppressions.line_suppressions.partition_point(|suppression| { + suppression.text_range.end() < entry.text_range.start() + }); + + if index >= self.suppressions.line_suppressions.len() { + None + } else { + Some(&mut self.suppressions.line_suppressions[index]) + } } };