Skip to content

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

fix: bug from last commit where idents would be flagged without suggestions

Elijah Potter03462cbb854e
diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rs
index 15a11b250..2a8814496 100644
--- a/harper-core/src/spell/full_dictionary.rs
+++ b/harper-core/src/spell/full_dictionary.rs
@@ -75,7 +75,8 @@ impl FullDictionary {
let mut word_len_starts = vec![0, 0];
for (index, len) in words.iter().map(SmallVec::len).enumerate() {
- if word_len_starts.len() == len {
+ if word_len_starts.len() <= len {
+ word_len_starts.resize(len, index);
word_len_starts.push(index);
}
}
diff --git a/harper-core/src/spell/merged_dictionary.rs b/harper-core/src/spell/merged_dictionary.rs
index 234b8b99f..01850660b 100644
--- a/harper-core/src/spell/merged_dictionary.rs
+++ b/harper-core/src/spell/merged_dictionary.rs
@@ -46,7 +46,7 @@ where
return true;
}
}
- return false;
+ false
}
fn words_iter(&self) -> impl Iterator<Item = &'_ [char]> {
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 46c8a449f..872f6e5c7 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -1,9 +1,6 @@
-use std::{collections::HashMap, process::id, sync::Arc};
+use std::{collections::HashMap, sync::Arc};
-use harper_core::{
- parsers::{Markdown, Parser},
- Document, FullDictionary, LintSet, Linter, MergedDictionary,
-};
+use harper_core::{parsers::Markdown, Document, FullDictionary, LintSet, Linter, MergedDictionary};
use tokio::sync::Mutex;
use tower_lsp::{
jsonrpc::Result,
diff --git a/harper-ls/src/tree_sitter_parser.rs b/harper-ls/src/tree_sitter_parser.rs
index b73b84744..154590182 100644
--- a/harper-ls/src/tree_sitter_parser.rs
+++ b/harper-ls/src/tree_sitter_parser.rs
@@ -56,13 +56,11 @@ impl TreeSitterParser {
let mut ident_spans = Vec::new();
let tree = self.parse_root(&text)?;
- Self::visit_nodes(
- &mut tree.walk(),
- &mut |node: &Node| match node.child_count() == 0 && node.kind().contains("ident") {
- true => ident_spans.push(node.byte_range().into()),
- false => (),
- },
- );
+ Self::visit_nodes(&mut tree.walk(), &mut |node: &Node| {
+ if node.child_count() == 0 && node.kind().contains("ident") {
+ ident_spans.push(node.byte_range().into())
+ }
+ });
byte_spans_to_char_spans(&mut ident_spans, &text);