Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(ls): move ignore action to bottom and respect `force_stable`

Elijah Potter843030eea437
diff --git a/harper-ls/src/diagnostics.rs b/harper-ls/src/diagnostics.rs
index 7673032fd..581a9a427 100644
--- a/harper-ls/src/diagnostics.rs
+++ b/harper-ls/src/diagnostics.rs
@@ -27,14 +27,7 @@ pub fn lint_to_code_actions<'a>(
source: &'a [char],
config: &CodeActionConfig,
) -> Vec<CodeActionOrCommand> {
- let mut results = vec![CodeActionOrCommand::Command(Command {
- title: "Ignore grammatical error.".to_owned(),
- command: "HarperIgnoreLint".to_owned(),
- arguments: Some(vec![
- serde_json::Value::String(url.to_string()),
- serde_json::to_value(lint).unwrap(),
- ]),
- })];
+ let mut results = Vec::new();
results.extend(
lint.suggestions
@@ -76,6 +69,15 @@ pub fn lint_to_code_actions<'a>(
.map(CodeActionOrCommand::CodeAction),
);
+ results.push(CodeActionOrCommand::Command(Command {
+ title: "Ignore Harper error.".to_owned(),
+ command: "HarperIgnoreLint".to_owned(),
+ arguments: Some(vec![
+ serde_json::Value::String(url.to_string()),
+ serde_json::to_value(lint).unwrap(),
+ ]),
+ }));
+
if lint.lint_kind.is_spelling() {
let orig = lint.span.get_content_string(source);
@@ -90,10 +92,10 @@ pub fn lint_to_code_actions<'a>(
"HarperAddToFileDict".to_string(),
Some(vec![orig.into(), url.to_string().into()]),
)));
+ }
- if config.force_stable {
- results.reverse();
- }
+ if config.force_stable {
+ results.reverse();
}
results