From ecbda9ac12a36f436ce7e0f0f1ca2131a5c8ba70 Mon Sep 17 00:00:00 2001 From: hippietrail Date: Thu, 5 Feb 2026 14:16:19 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20don't=20flag=20more=20foreign=20?= =?UTF-8?q?=E2=86=92=20foreigner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- harper-core/src/linting/more_adjective.rs | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/harper-core/src/linting/more_adjective.rs b/harper-core/src/linting/more_adjective.rs index 97b0fd3f9..f740459de 100644 --- a/harper-core/src/linting/more_adjective.rs +++ b/harper-core/src/linting/more_adjective.rs @@ -1,11 +1,12 @@ use itertools::Itertools; -use crate::expr::{Expr, SequenceExpr}; -use crate::linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk}; -use crate::spell::Dictionary; -use crate::{CharStringExt, Lint, Token, TokenStringExt}; - -const VOWELS: [char; 5] = ['a', 'e', 'i', 'o', 'u']; +use crate::{ + char_ext::CharExt, + expr::{Expr, SequenceExpr}, + linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk}, + spell::Dictionary, + {CharStringExt, Lint, Token, TokenStringExt}, +}; pub struct MoreAdjective { expr: Box, @@ -88,8 +89,9 @@ where return None; } + // "foreigner" is a noun, not an adjective "more foreign" // "humaner" = "more humane", not "more human" - if adj_str == "human" { + if adj_str == "foreign" || adj_str == "human" { return None; } @@ -121,7 +123,7 @@ where // Double consonant: big -> bigger/biggest let penult = adj_chars[adj_chars.len() - 2]; let last = adj_chars[adj_chars.len() - 1]; - if VOWELS.contains(&penult) && !VOWELS.contains(&last) { + if penult.is_vowel() && !last.is_vowel() { self.add_valid_candidate(&mut candidates, format!("{}{}{}", adj_str, last, ending)); } @@ -299,4 +301,12 @@ mod tests { MoreAdjective::new(FstDictionary::curated()), ); } + + #[test] + fn dont_flag_more_foreign() { + assert_no_lints( + "There are more foreign visitors this year.", + MoreAdjective::new(FstDictionary::curated()), + ); + } }