Skip to content

Commit

Permalink
fix(ls): potential deadlock causing #486
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Jan 24, 2025
1 parent 24baa04 commit e4251ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion harper-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,16 @@ impl Backend {
url: &Url,
range: Range,
) -> JsonResult<Vec<CodeActionOrCommand>> {
let (config, mut doc_states) = tokio::join!(self.config.read(), self.doc_state.lock());
let (config_guard, mut doc_states) =
tokio::join!(self.config.read(), self.doc_state.lock());
let Some(doc_state) = doc_states.get_mut(url) else {
return Ok(Vec::new());
};

// Allow writes as soon as possible to avoid deadlocks
let config = config_guard.clone();
drop(config_guard);

let mut lints = doc_state.linter.lint(&doc_state.document);
lints.sort_by_key(|l| l.priority);

Expand Down

0 comments on commit e4251ac

Please sign in to comment.