fix: properly await async operations in document handling

This commit is contained in:
Josh Thomas 2025-01-07 12:02:39 -06:00
parent cd0b63f07b
commit 4b471a3c03
2 changed files with 4 additions and 3 deletions

View file

@ -41,15 +41,16 @@ impl Store {
Ok(()) Ok(())
} }
pub fn publish_diagnostics(&self, uri: &str, client: &Client) { pub async fn publish_diagnostics(&self, uri: &str, client: &Client) -> Result<()> {
if let Some(document) = self.get_document(uri) { if let Some(document) = self.get_document(uri) {
let diagnostics = Diagnostics::generate_for_document(document); let diagnostics = Diagnostics::generate_for_document(document);
client.publish_diagnostics( client.publish_diagnostics(
Url::parse(uri).unwrap(), Url::parse(uri).unwrap(),
diagnostics, diagnostics,
Some(document.version), Some(document.version),
); ).await;
} }
Ok(())
} }
pub fn handle_did_change( pub fn handle_did_change(

View file

@ -110,7 +110,7 @@ impl LanguageServer for DjangoLanguageServer {
} }
async fn did_open(&self, params: DidOpenTextDocumentParams) { async fn did_open(&self, params: DidOpenTextDocumentParams) {
if let Err(e) = self.documents.write().await.handle_did_open(params.clone(), &self.client) { if let Err(e) = self.documents.write().await.handle_did_open(params.clone(), &self.client).await {
eprintln!("Error handling document open: {}", e); eprintln!("Error handling document open: {}", e);
return; return;
} }