Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): use standard `AnyCapitalization` linter instead.
Elijah Pottercdd4a436afdb
diff --git a/Cargo.toml b/Cargo.tomlindex c40249357..05f7ccd19 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,5 +1,4 @@[workspace]- #[cached]members = [ "harper-cli", "harper-core", "harper-ls", "harper-comments", "harper-wasm", "harper-tree-sitter", "harper-html", "harper-literate-haskell", "harper-typst" ]resolver = "2"diff --git a/harper-core/src/linting/that_which.rs b/harper-core/src/linting/that_which.rsindex c6664b26b..0edf12ad4 100644--- a/harper-core/src/linting/that_which.rs+++ b/harper-core/src/linting/that_which.rs@@ -17,9 +17,9 @@ impl Default for ThatWhich {let matching_pattern = Lrc::new(SequencePattern::default()- .then_exact_word_or_lowercase("That")+ .then_any_capitalization_of("that").then_whitespace()- .then_exact_word("that"),+ .then_any_capitalization_of("that"),);pattern.add("that", Box::new(matching_pattern.clone()));diff --git a/harper-core/src/linting/use_genitive.rs b/harper-core/src/linting/use_genitive.rsindex b33842104..83be96161 100644--- a/harper-core/src/linting/use_genitive.rs+++ b/harper-core/src/linting/use_genitive.rs@@ -40,8 +40,8 @@ impl UseGenitive {// Add a prelude to remove false-positives.let full_pattern = SequencePattern::default().then(Invert::new(EitherPattern::new(vec![- Box::new(SequencePattern::default().then_exact_word_or_lowercase("Is")),- Box::new(SequencePattern::default().then_exact_word_or_lowercase("Were")),+ Box::new(SequencePattern::default().t_aco("is")),+ Box::new(SequencePattern::default().t_aco("were")),Box::new(SequencePattern::default().then_adjective()),]))).then_whitespace()diff --git a/harper-core/src/patterns/sequence_pattern.rs b/harper-core/src/patterns/sequence_pattern.rsindex c2fc8c2bb..770223b23 100644--- a/harper-core/src/patterns/sequence_pattern.rs+++ b/harper-core/src/patterns/sequence_pattern.rs@@ -4,7 +4,7 @@ use super::whitespace_pattern::WhitespacePattern;use super::{AnyCapitalization, AnyPattern, IndefiniteArticle, Pattern, RepeatingPattern, SingularSubject,};-use crate::{CharStringExt, Token, TokenKind};+use crate::{Token, TokenKind};/// A pattern that checks that a sequence of other patterns match./// There are specific extension methods available, but you can also use [`Self::then`] to add@@ -137,40 +137,14 @@ impl SequencePattern {self}- /// Shorthand for [`Self::then_exact_word_or_lowercase`].- pub fn t_eworl(self, word: &'static str) -> Self {- self.then_exact_word_or_lowercase(word)- }-- pub fn then_exact_word_or_lowercase(mut self, word: &'static str) -> Self {- self.token_patterns- .push(Box::new(|tok: &Token, source: &[char]| {- if !tok.kind.is_word() {- return false;- }-- let tok_chars = tok.span.get_content(source).to_lower();-- let mut w_char_count = 0;- for (i, w_char) in word.to_lowercase().chars().enumerate() {- w_char_count += 1;-- if tok_chars.get(i).cloned() != Some(w_char) {- return false;- }- }-- w_char_count == tok_chars.len()- }));- self- }-+ /// Matches any word.pub fn then_any_word(mut self) -> Self {self.token_patterns.push(Box::new(|tok: &Token, _source: &[char]| tok.kind.is_word()));self}+ /// Matches any token whose `Kind` exactly matches.pub fn then_strict(mut self, kind: TokenKind) -> Self {self.token_patterns.push(Box::new(move |tok: &Token, _source: &[char]| {