Skip to content

Commit d854fbb

Browse files
committed
Unbatch updates for simpler queue
1 parent bdaf4e7 commit d854fbb

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

crates/ark/src/lsp/main_loop.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -808,26 +808,6 @@ async fn process_indexer_batch(batch: Vec<IndexerTask>) {
808808
summary = summarize_indexer_task(&batch)
809809
);
810810

811-
let mut updates: HashMap<PathBuf, IndexerTask> = HashMap::new();
812-
813-
fn flush_updates(
814-
updates: &mut HashMap<PathBuf, IndexerTask>,
815-
) -> Vec<tokio::task::JoinHandle<()>> {
816-
tracing::trace!("Flushing {n} update tasks", n = updates.len());
817-
818-
let mut handles = Vec::new();
819-
for (path, task) in updates.drain() {
820-
handles.push(tokio::task::spawn_blocking(move || {
821-
if let IndexerTask::Update { document, .. } = task {
822-
if let Err(err) = indexer::update(&document, &path) {
823-
log::warn!("Indexer update failed: {err}");
824-
}
825-
}
826-
}));
827-
}
828-
handles
829-
}
830-
831811
let to_path_buf = |uri: &url::Url| {
832812
uri.to_file_path()
833813
.map_err(|_| anyhow!("Failed to convert URI '{uri}' to file path"))
@@ -841,16 +821,12 @@ async fn process_indexer_batch(batch: Vec<IndexerTask>) {
841821
indexer::create(&path)?;
842822
},
843823

844-
IndexerTask::Update { uri, .. } => {
824+
IndexerTask::Update { uri, document } => {
845825
let path = to_path_buf(uri)?;
846-
updates.insert(path, task);
826+
indexer::update(&document, &path)?;
847827
},
848828

849829
IndexerTask::Delete { uri } => {
850-
let handles = flush_updates(&mut updates);
851-
for handle in handles {
852-
let _ = handle.await;
853-
}
854830
let path = to_path_buf(uri)?;
855831
indexer::delete(&path)?;
856832
},
@@ -859,11 +835,6 @@ async fn process_indexer_batch(batch: Vec<IndexerTask>) {
859835
uri: old_uri,
860836
new: new_uri,
861837
} => {
862-
let handles = flush_updates(&mut updates);
863-
for handle in handles {
864-
let _ = handle.await;
865-
}
866-
867838
let old_path = to_path_buf(old_uri)?;
868839
let new_path = to_path_buf(new_uri)?;
869840

@@ -880,11 +851,6 @@ async fn process_indexer_batch(batch: Vec<IndexerTask>) {
880851
continue;
881852
}
882853
}
883-
884-
let handles = flush_updates(&mut updates);
885-
for handle in handles {
886-
let _ = handle.await;
887-
}
888854
}
889855

890856
async fn process_diagnostics_batch(batch: Vec<RefreshDiagnosticsTask>) {

0 commit comments

Comments
 (0)