From feeda7fa378359c18fcbb9c14a64db101188c199 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 2 Jun 2025 20:12:58 -0600 Subject: [PATCH] Add newlines between messages in LSP RPC logs for more navigability (#31863) Release Notes: - N/A --- crates/language_tools/src/lsp_log.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 3acb1cb2b0..f88b474ded 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -20,8 +20,8 @@ use workspace::{ searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle}, }; -const SEND_LINE: &str = "// Send:"; -const RECEIVE_LINE: &str = "// Receive:"; +const SEND_LINE: &str = "// Send:\n"; +const RECEIVE_LINE: &str = "// Receive:\n"; const MAX_STORED_LOG_ENTRIES: usize = 2000; pub struct LogStore { @@ -464,8 +464,7 @@ impl LogStore { while log_lines.len() >= MAX_STORED_LOG_ENTRIES { log_lines.pop_front(); } - let entry: &str = message.as_ref(); - let entry = entry.to_string(); + let entry = format!("{}\n", message.as_ref().trim()); let visible = message.should_include(current_severity); log_lines.push_back(message); @@ -580,7 +579,7 @@ impl LogStore { }); cx.emit(Event::NewServerLogEntry { id: language_server_id, - entry: message.to_string(), + entry: format!("{}\n\n", message), kind: LogKind::Rpc, }); cx.notify(); @@ -644,13 +643,7 @@ impl LspLogView { let last_point = editor.buffer().read(cx).len(cx); let newest_cursor_is_at_end = editor.selections.newest::(cx).start >= last_point; - editor.edit( - vec![ - (last_point..last_point, entry.trim()), - (last_point..last_point, "\n"), - ], - cx, - ); + editor.edit(vec![(last_point..last_point, entry.as_str())], cx); let entry_length = entry.len(); if entry_length > 1024 { editor.fold_ranges(