Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(wasm): remove overlaps in the proper order (#2062)
Elijah Potter292998567377
diff --git a/harper-wasm/src/lib.rs b/harper-wasm/src/lib.rsindex bf00de814..66e47d900 100644--- a/harper-wasm/src/lib.rs+++ b/harper-wasm/src/lib.rs@@ -266,11 +266,12 @@ impl Linter {self.lint_group.config = temp;- remove_overlaps_map(&mut lints);for value in lints.values_mut() {self.ignored_lints.remove_ignored(value, &document);}+ remove_overlaps_map(&mut lints);+lints.into_iter().map(|(s, ls)| OrganizedGroup {@@ -302,8 +303,8 @@ impl Linter {self.lint_group.config = temp;- remove_overlaps(&mut lints);self.ignored_lints.remove_ignored(&mut lints, &document);+ remove_overlaps(&mut lints);lints.into_iter()diff --git a/packages/harper.js/src/Linter.test.ts b/packages/harper.js/src/Linter.test.tsindex d43b1c78c..b217c9fa9 100644--- a/packages/harper.js/src/Linter.test.ts+++ b/packages/harper.js/src/Linter.test.ts@@ -225,6 +225,21 @@ for (const [linterName, Linter] of Object.entries(linters)) {expect(secondRound.length).toBeLessThan(firstRound.length);});+ test(`${linterName} can ignore larger lints to reveal smaller ones`, async () => {+ const linter = new Linter({ binary });+ const source = `This is a really long sentensd with some errorz in it, which in an old version of Harper, would get removedd when the bigger "Long Sentences" lint was ignored, that isn't what we woant, so we are writing a test for that exact problem.`;++ const firstRound = await linter.lint(source);++ expect(firstRound.length).toBeGreaterThanOrEqual(1);++ await linter.ignoreLint(source, firstRound[0]);++ const secondRound = await linter.lint(source);++ expect(secondRound.length).toBe(4);+ });+test(`${linterName} can reimport ignored lints.`, async () => {const source = 'This is an test of xporting lints.';