Add newlines between messages in LSP RPC logs for more navigability (#31863)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-02 20:12:58 -06:00 committed by GitHub
parent 4a5c55a8f2
commit feeda7fa37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,8 +20,8 @@ use workspace::{
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle}, searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
}; };
const SEND_LINE: &str = "// Send:"; const SEND_LINE: &str = "// Send:\n";
const RECEIVE_LINE: &str = "// Receive:"; const RECEIVE_LINE: &str = "// Receive:\n";
const MAX_STORED_LOG_ENTRIES: usize = 2000; const MAX_STORED_LOG_ENTRIES: usize = 2000;
pub struct LogStore { pub struct LogStore {
@ -464,8 +464,7 @@ impl LogStore {
while log_lines.len() >= MAX_STORED_LOG_ENTRIES { while log_lines.len() >= MAX_STORED_LOG_ENTRIES {
log_lines.pop_front(); log_lines.pop_front();
} }
let entry: &str = message.as_ref(); let entry = format!("{}\n", message.as_ref().trim());
let entry = entry.to_string();
let visible = message.should_include(current_severity); let visible = message.should_include(current_severity);
log_lines.push_back(message); log_lines.push_back(message);
@ -580,7 +579,7 @@ impl LogStore {
}); });
cx.emit(Event::NewServerLogEntry { cx.emit(Event::NewServerLogEntry {
id: language_server_id, id: language_server_id,
entry: message.to_string(), entry: format!("{}\n\n", message),
kind: LogKind::Rpc, kind: LogKind::Rpc,
}); });
cx.notify(); cx.notify();
@ -644,13 +643,7 @@ impl LspLogView {
let last_point = editor.buffer().read(cx).len(cx); let last_point = editor.buffer().read(cx).len(cx);
let newest_cursor_is_at_end = let newest_cursor_is_at_end =
editor.selections.newest::<usize>(cx).start >= last_point; editor.selections.newest::<usize>(cx).start >= last_point;
editor.edit( editor.edit(vec![(last_point..last_point, entry.as_str())], cx);
vec![
(last_point..last_point, entry.trim()),
(last_point..last_point, "\n"),
],
cx,
);
let entry_length = entry.len(); let entry_length = entry.len();
if entry_length > 1024 { if entry_length > 1024 {
editor.fold_ranges( editor.fold_ranges(