diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index ee39a2790bc..8bcdca5bb82 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -494,7 +494,7 @@ fn spawn(mut command: Command) -> std::io::Result { let (sender, receiver) = unbounded(); let actor = CargoActor::new(sender, stdout, stderr); let thread = stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker) - .name("CargoHandle".to_owned()) + .name("CommandHandle".to_owned()) .spawn(move || actor.run()) .expect("failed to spawn thread"); Ok(CommandHandle { program, arguments, current_dir, child, thread, receiver }) diff --git a/crates/ide-db/src/prime_caches.rs b/crates/ide-db/src/prime_caches.rs index 4fc9dc95a64..ef15f585fa2 100644 --- a/crates/ide-db/src/prime_caches.rs +++ b/crates/ide-db/src/prime_caches.rs @@ -82,6 +82,7 @@ enum ParallelPrimeCacheWorkerProgress { stdx::thread::Builder::new(stdx::thread::ThreadIntent::Worker) .allow_leak(true) + .name("PrimeCaches".to_owned()) .spawn(move || Cancelled::catch(|| worker(db))) .expect("failed to spawn thread"); } diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs index b13c709dbfe..e082c083507 100644 --- a/crates/rust-analyzer/src/handlers/notification.rs +++ b/crates/rust-analyzer/src/handlers/notification.rs @@ -90,18 +90,13 @@ pub(crate) fn handle_did_change_text_document( let _p = tracing::span!(tracing::Level::INFO, "handle_did_change_text_document").entered(); if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { - let data = match state.mem_docs.get_mut(&path) { - Some(doc) => { - // The version passed in DidChangeTextDocument is the version after all edits are applied - // so we should apply it before the vfs is notified. - doc.version = params.text_document.version; - &mut doc.data - } - None => { - tracing::error!("unexpected DidChangeTextDocument: {}", path); - return Ok(()); - } + let Some(DocumentData { version, data }) = state.mem_docs.get_mut(&path) else { + tracing::error!("unexpected DidChangeTextDocument: {}", path); + return Ok(()); }; + // The version passed in DidChangeTextDocument is the version after all edits are applied + // so we should apply it before the vfs is notified. + *version = params.text_document.version; let new_contents = apply_document_changes( state.config.position_encoding(), diff --git a/lib/lsp-server/src/stdio.rs b/lib/lsp-server/src/stdio.rs index cea199d0293..c28545fb574 100644 --- a/lib/lsp-server/src/stdio.rs +++ b/lib/lsp-server/src/stdio.rs @@ -12,27 +12,33 @@ /// Creates an LSP connection via stdio. pub(crate) fn stdio_transport() -> (Sender, Receiver, IoThreads) { let (writer_sender, writer_receiver) = bounded::(0); - let writer = thread::spawn(move || { - let stdout = stdout(); - let mut stdout = stdout.lock(); - writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout)) - }); + let writer = thread::Builder::new() + .name("LspServerWriter".to_owned()) + .spawn(move || { + let stdout = stdout(); + let mut stdout = stdout.lock(); + writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout)) + }) + .unwrap(); let (reader_sender, reader_receiver) = bounded::(0); - let reader = thread::spawn(move || { - let stdin = stdin(); - let mut stdin = stdin.lock(); - while let Some(msg) = Message::read(&mut stdin)? { - let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit()); + let reader = thread::Builder::new() + .name("LspServerReader".to_owned()) + .spawn(move || { + let stdin = stdin(); + let mut stdin = stdin.lock(); + while let Some(msg) = Message::read(&mut stdin)? { + let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit()); - debug!("sending message {:#?}", msg); - reader_sender.send(msg).expect("receiver was dropped, failed to send a message"); + debug!("sending message {:#?}", msg); + reader_sender.send(msg).expect("receiver was dropped, failed to send a message"); - if is_exit { - break; + if is_exit { + break; + } } - } - Ok(()) - }); + Ok(()) + }) + .unwrap(); let threads = IoThreads { reader, writer }; (writer_sender, reader_receiver, threads) }