Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(chrome-ext): suggestions being displayed as `0` (#2757)
Elijah Pottera0a5c55eb33d
diff --git a/harper-core/src/linting/single_be.rs b/harper-core/src/linting/single_be.rsindex e7fcd178f..fb01bfdba 100644--- a/harper-core/src/linting/single_be.rs+++ b/harper-core/src/linting/single_be.rs@@ -160,7 +160,7 @@ impl ExprLinter for SingleBe {Some(Lint {span: Span::new(whitespace_start, second_be_end),lint_kind: LintKind::Grammar,- suggestions: vec![Suggestion::ReplaceWith(vec![])],+ suggestions: vec![Suggestion::Remove],message: "Drop the repeated verb form so only one instance of `be` remains.".to_owned(),priority: 31,})diff --git a/packages/lint-framework/src/lint/SuggestionBox.ts b/packages/lint-framework/src/lint/SuggestionBox.tsindex c7f50543d..c7c08f98b 100644--- a/packages/lint-framework/src/lint/SuggestionBox.ts+++ b/packages/lint-framework/src/lint/SuggestionBox.ts@@ -1,6 +1,7 @@/** biome-ignore-all lint/complexity/useArrowFunction: It cannot be an arrow function for the logic to work. */import { type IconDefinition, icon } from '@fortawesome/fontawesome-svg-core';import { faBan, faGear } from '@fortawesome/free-solid-svg-icons';+import { SuggestionKind } from 'harper.js';import type { VNode } from 'virtual-dom';import h from 'virtual-dom/h';import bookDownSvg from '../assets/bookDownSvg';@@ -201,7 +202,8 @@ function suggestions(apply: (s: UnpackedSuggestion) => void,): any {return suggestions.map((s: UnpackedSuggestion, i: number) => {- const label = s.replacement_text !== '' ? s.replacement_text : String(s.kind);+ const label =+ s.replacement_text !== '' ? s.replacement_text : String(suggestionKindToLabel(s.kind));const desc = `Replace with "${label}"`;const props = i === 0 ? { hook: new FocusHook() } : {};return button(@@ -214,6 +216,17 @@ function suggestions(});}+function suggestionKindToLabel(s: SuggestionKind): string {+ switch (s) {+ case SuggestionKind.Replace:+ return 'Replace';+ case SuggestionKind.Remove:+ return 'Remove';+ case SuggestionKind.InsertAfter:+ return 'Insert After';+ }+}+function reportProblemButton(reportError?: () => Promise<void>): any {if (!reportError) {return undefined;