Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
Publish diagnostics more often + improve spell check message
Elijah Potterbdba19563a20
diff --git a/harper-core/src/document.rs b/harper-core/src/document.rsindex d83cd6f79..573558daa 100644--- a/harper-core/src/document.rs+++ b/harper-core/src/document.rs@@ -125,12 +125,12 @@ impl Document {span.get_content(&self.source)}- pub fn get_content_string(&self, span: Span) -> String {+ pub fn get_span_content_str(&self, span: Span) -> String {String::from_iter(self.get_span_content(span))}pub fn get_full_string(&self) -> String {- self.get_content_string(Span {+ self.get_span_content_str(Span {start: 0,end: self.source.len(),})@@ -160,7 +160,7 @@ impl Document {impl Display for Document {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {for token in &self.tokens {- write!(f, "{}", self.get_content_string(token.span))?;+ write!(f, "{}", self.get_span_content_str(token.span))?;}Ok(())diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rsindex f516649a2..85dee2308 100644--- a/harper-core/src/linting/spell_check.rs+++ b/harper-core/src/linting/spell_check.rs@@ -23,7 +23,10 @@ pub fn spell_check(document: &Document, _dictionary: &Dictionary) -> Vec<Lint> {span: word.span,lint_kind: LintKind::Spelling,suggestions: suggestions.collect(),- message: "Did you mean to spell it this way?".to_string(),+ message: format!(+ "Did you mean to spell “{}” this way?",+ document.get_span_content_str(word.span)+ ),})}diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rsindex 69c833b1f..25a2209c6 100644--- a/harper-ls/src/backend.rs+++ b/harper-ls/src/backend.rs@@ -66,19 +66,23 @@ impl LanguageServer for Backend {self.publish_diagnostics(¶ms.text_document.uri).await;}- async fn did_open(&self, _: DidOpenTextDocumentParams) {+ async fn did_open(&self, params: DidOpenTextDocumentParams) {self.client.log_message(MessageType::INFO, "File opened!").await;++ self.publish_diagnostics(¶ms.text_document.uri).await;}- async fn did_change(&self, _: DidChangeTextDocumentParams) {+ async fn did_change(&self, params: DidChangeTextDocumentParams) {self.client.log_message(MessageType::INFO, "File changed!").await;++ self.publish_diagnostics(¶ms.text_document.uri).await;}- async fn did_close(&self, _: DidCloseTextDocumentParams) {+ async fn did_close(&self, params: DidCloseTextDocumentParams) {self.client.log_message(MessageType::INFO, "File closed!").await;