Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
LSP debug logs: Default to soft wrap + fold long lines + autoscroll (#22996)
Michael Sloanbbbd1e9902e1
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 6d87575e96e..4334a34bf08 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -10901,6 +10901,20 @@ impl Editor {self.fold_creases(ranges, true, cx);}+ pub fn fold_ranges<T: ToOffset + Clone>(+ &mut self,+ ranges: Vec<Range<T>>,+ auto_scroll: bool,+ cx: &mut ViewContext<Self>,+ ) {+ let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));+ let ranges = ranges+ .into_iter()+ .map(|r| Crease::simple(r, display_map.fold_placeholder.clone()))+ .collect::<Vec<_>>();+ self.fold_creases(ranges, auto_scroll, cx);+ }+pub fn fold_creases<T: ToOffset + Clone>(&mut self,creases: Vec<Crease<T>>,diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rsindex b4883943335..66c6fb14d47 100644--- a/crates/language_tools/src/lsp_log.rs+++ b/crates/language_tools/src/lsp_log.rs@@ -1,13 +1,13 @@use collections::{HashMap, VecDeque};use copilot::Copilot;-use editor::{actions::MoveToEnd, Editor, EditorEvent};+use editor::{actions::MoveToEnd, scroll::Autoscroll, Editor, EditorEvent};use futures::{channel::mpsc, StreamExt};use gpui::{actions, div, AppContext, Context, Corner, EventEmitter, FocusHandle, FocusableView,IntoElement, Model, ModelContext, ParentElement, Render, Styled, Subscription, View,ViewContext, VisualContext, WeakModel, WindowContext,};-use language::LanguageServerId;+use language::{language_settings::SoftWrap, LanguageServerId};use lsp::{notification::SetTrace, IoKind, LanguageServer, LanguageServerName, MessageType,SetTraceParams, TraceValue,@@ -649,6 +649,15 @@ impl LspLogView {],cx,);+ let entry_length = entry.len();+ if entry_length > 1024 {+ editor.fold_ranges(+ vec![last_point + 1024..last_point + entry_length],+ false,+ cx,+ );+ }+ editor.request_autoscroll(Autoscroll::fit(), cx);editor.set_read_only(true);});}@@ -691,6 +700,7 @@ impl LspLogView {editor.move_to_end(&MoveToEnd, cx);editor.set_read_only(true);editor.set_show_inline_completions(Some(false), cx);+ editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);editor});let editor_subscription = cx.subscribe(@@ -728,6 +738,7 @@ impl LspLogView {editor.set_text(server_info, cx);editor.set_read_only(true);editor.set_show_inline_completions(Some(false), cx);+ editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);editor});let editor_subscription = cx.subscribe(