Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(core): #341 by adding check to make sure we don't include `*-only`
Elijah Potterb56af6b9dc57
diff --git a/harper-core/src/linting/terminating_conjunctions.rs b/harper-core/src/linting/terminating_conjunctions.rsindex 9b0bb5c2b..cc2af7d66 100644--- a/harper-core/src/linting/terminating_conjunctions.rs+++ b/harper-core/src/linting/terminating_conjunctions.rs@@ -11,6 +11,7 @@ impl Default for TerminatingConjunctions {Self {pattern: Box::new(ConsumesRemainingPattern::new(Box::new(SequencePattern::default()+ .then_anything_but_hyphen().then_any_word_in(Lrc::new(["although",@@ -92,4 +93,13 @@ mod tests {fn no_false_positive() {assert_lint_count("Cookies and milk.", TerminatingConjunctions::default(), 0)}++ #[test]+ fn issue_341() {+ assert_lint_count(+ "The structure has a couple of fields marked read-only, like A and B",+ TerminatingConjunctions::default(),+ 0,+ );+ }}diff --git a/harper-core/src/patterns/sequence_pattern.rs b/harper-core/src/patterns/sequence_pattern.rsindex 239f36dbd..afb9eeb08 100644--- a/harper-core/src/patterns/sequence_pattern.rs+++ b/harper-core/src/patterns/sequence_pattern.rs@@ -27,6 +27,18 @@ macro_rules! gen_then_from_is {tok.kind.[< is_$quality >]()}))}++ pub fn [< then_anything_but_$quality >] (mut self) -> Self{+ self.token_patterns.push(Box::new(|tok: &Token, _source: &[char]| {+ if tok.kind.[< is_$quality >](){+ false+ }else{+ true+ }+ }));++ self+ }}};}@@ -43,6 +55,7 @@ impl SequencePattern {gen_then_from_is!(case_separator);gen_then_from_is!(adverb);gen_then_from_is!(adjective);+ gen_then_from_is!(hyphen);pub fn then_exact_word(mut self, word: &'static str) -> Self {self.token_patternsdiff --git a/harper-core/src/token.rs b/harper-core/src/token.rsindex 2105c8408..5d08ebb7c 100644--- a/harper-core/src/token.rs+++ b/harper-core/src/token.rs@@ -130,6 +130,10 @@ impl TokenKind {matches!(self, TokenKind::Punctuation(Punctuation::Ellipsis))}+ pub fn is_hyphen(&self) -> bool {+ matches!(self, TokenKind::Punctuation(Punctuation::Hyphen))+ }+pub fn is_adjective(&self) -> bool {matches!(self,