Skip to content

Commit

Permalink
fix: harper-ls will now clear diagnostics on :LspStop
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Oct 1, 2024
1 parent 739bc0a commit 8e9afbb
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions harper-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ impl LanguageServer for Backend {
self.pull_config().await;
}

async fn shutdown(&self) -> Result<()> {
Ok(())
}

async fn did_save(&self, params: DidSaveTextDocumentParams) {
let _ = self
.update_document_from_file(&params.text_document.uri, None)
Expand Down Expand Up @@ -476,4 +472,23 @@ impl LanguageServer for Backend {

Ok(Some(actions))
}

async fn shutdown(&self) -> Result<()> {
let doc_states = self.doc_state.lock().await;

// Clears the diagnostics for open buffers.
for url in doc_states.keys() {
let result = PublishDiagnosticsParams {
uri: url.clone(),
diagnostics: vec![],
version: None,
};

self.client
.send_notification::<PublishDiagnostics>(result)
.await;
}

Ok(())
}
}

0 comments on commit 8e9afbb

Please sign in to comment.