From 92b9bc599dc95582e027b5a97dcc421243d27b89 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 28 Apr 2025 14:17:21 -0400 Subject: [PATCH] format: Minor logging improvements (#29554) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/project/src/lsp_store.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 0584b5551348aa144adc5a704088e82a3f8a24ee..eea22322e38d8276ef36dcc8bb637d579bd5a3b0 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -1187,6 +1187,11 @@ impl LocalLspStore { let mut project_transaction = ProjectTransaction::default(); for buffer in &buffers { + zlog::debug!( + logger => + "formatting buffer '{:?}'", + buffer.abs_path.as_ref().unwrap_or(&PathBuf::from("unknown")).display() + ); // Create an empty transaction to hold all of the formatting edits. let formatting_transaction_id = buffer.handle.update(cx, |buffer, cx| { // ensure no transactions created while formatting are @@ -1224,6 +1229,7 @@ impl LocalLspStore { return; }; if formatting_transaction.edit_ids.is_empty() { + zlog::debug!(logger => "no changes made while formatting"); buffer.forget_transaction(formatting_transaction_id); return; } @@ -1265,8 +1271,8 @@ impl LocalLspStore { }) })?; - // Apply edits to the buffer that will become part of the formatting transaction. - // Fails if the buffer has been edited since the start of that transaction. + /// Apply edits to the buffer that will become part of the formatting transaction. + /// Fails if the buffer has been edited since the start of that transaction. fn extend_formatting_transaction( buffer: &FormattableBuffer, formatting_transaction_id: text::TransactionId, @@ -1930,8 +1936,7 @@ impl LocalLspStore { let range_formatting_provider = capabilities.document_range_formatting_provider.as_ref(); let lsp_edits = if matches!(formatting_provider, Some(p) if *p != OneOf::Left(false)) { - let _timer = zlog::time!(logger => "format-full") - .warn_if_gt(std::time::Duration::from_millis(0)); + let _timer = zlog::time!(logger => "format-full"); language_server .request::(lsp::DocumentFormattingParams { text_document, @@ -1940,8 +1945,7 @@ impl LocalLspStore { }) .await? } else if matches!(range_formatting_provider, Some(p) if *p != OneOf::Left(false)) { - let _timer = zlog::time!(logger => "format-range") - .warn_if_gt(std::time::Duration::from_millis(0)); + let _timer = zlog::time!(logger => "format-range"); let buffer_start = lsp::Position::new(0, 0); let buffer_end = buffer.update(cx, |b, _| point_to_lsp(b.max_point_utf16()))?; language_server