language_tools: Increase available space for language server logs (#30742)

This PR contains some small improvements for the language server log
editors. Due to the large gutter as well as the introduction of the
minimap, the horizontally available space was rather small. As these
editors soft wrap at the editor width, it resulted in the logs becoming
vertically larger and somewhat harder to read.

The improvement here is to disable all elements in the gutter that will
never appear or be used in the logs anyway. Furthermore, I opted to
disable the minimap altogether, since from my point of view it did not
contain any valuable information about the logs being shown.

First image is the current main, second is this branch. I put these
below each other so the difference is easier to spot.


![main](https://github.com/user-attachments/assets/b3796e5f-4fe3-48c8-95a4-d3b84c607963)

![PR](https://github.com/user-attachments/assets/bd8a4e6c-dbbb-4a9e-99aa-474fa073196f)


Release Notes:

- N/A
This commit is contained in:
Finn Evers 2025-05-26 23:57:45 +02:00 committed by GitHub
parent 6840a4e5bc
commit 2c8049270a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 94 additions and 42 deletions

View file

@ -702,15 +702,7 @@ impl LspLogView {
window: &mut Window,
cx: &mut Context<Self>,
) -> (Entity<Editor>, Vec<Subscription>) {
let editor = cx.new(|cx| {
let mut editor = Editor::multi_line(window, cx);
editor.set_text(log_contents, window, cx);
editor.move_to_end(&MoveToEnd, window, cx);
editor.set_read_only(true);
editor.set_show_edit_predictions(Some(false), window, cx);
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor
});
let editor = initialize_new_editor(log_contents, true, window, cx);
let editor_subscription = cx.subscribe(
&editor,
|_, _, event: &EditorEvent, cx: &mut Context<LspLogView>| cx.emit(event.clone()),
@ -727,10 +719,8 @@ impl LspLogView {
window: &mut Window,
cx: &mut Context<Self>,
) -> (Entity<Editor>, Vec<Subscription>) {
let editor = cx.new(|cx| {
let mut editor = Editor::multi_line(window, cx);
let server_info = format!(
"* Server: {NAME} (id {ID})
let server_info = format!(
"* Server: {NAME} (id {ID})
* Binary: {BINARY:#?}
@ -740,29 +730,24 @@ impl LspLogView {
* Capabilities: {CAPABILITIES}
* Configuration: {CONFIGURATION}",
NAME = server.name(),
ID = server.server_id(),
BINARY = server.binary(),
WORKSPACE_FOLDERS = server
.workspace_folders()
.iter()
.filter_map(|path| path
.to_file_path()
.ok()
.map(|path| path.to_string_lossy().into_owned()))
.collect::<Vec<_>>()
.join(", "),
CAPABILITIES = serde_json::to_string_pretty(&server.capabilities())
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
CONFIGURATION = serde_json::to_string_pretty(server.configuration())
.unwrap_or_else(|e| format!("Failed to serialize configuration: {e}")),
);
editor.set_text(server_info, window, cx);
editor.set_read_only(true);
editor.set_show_edit_predictions(Some(false), window, cx);
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor
});
NAME = server.name(),
ID = server.server_id(),
BINARY = server.binary(),
WORKSPACE_FOLDERS = server
.workspace_folders()
.iter()
.filter_map(|path| path
.to_file_path()
.ok()
.map(|path| path.to_string_lossy().into_owned()))
.collect::<Vec<_>>()
.join(", "),
CAPABILITIES = serde_json::to_string_pretty(&server.capabilities())
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
CONFIGURATION = serde_json::to_string_pretty(server.configuration())
.unwrap_or_else(|e| format!("Failed to serialize configuration: {e}")),
);
let editor = initialize_new_editor(server_info, false, window, cx);
let editor_subscription = cx.subscribe(
&editor,
|_, _, event: &EditorEvent, cx: &mut Context<LspLogView>| cx.emit(event.clone()),
@ -1550,6 +1535,29 @@ impl Render for LspLogToolbarItemView {
}
}
fn initialize_new_editor(
content: String,
move_to_end: bool,
window: &mut Window,
cx: &mut App,
) -> Entity<Editor> {
cx.new(|cx| {
let mut editor = Editor::multi_line(window, cx);
editor.hide_minimap_by_default(window, cx);
editor.set_text(content, window, cx);
editor.set_show_git_diff_gutter(false, cx);
editor.set_show_runnables(false, cx);
editor.set_show_breakpoints(false, cx);
editor.set_read_only(true);
editor.set_show_edit_predictions(Some(false), window, cx);
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
if move_to_end {
editor.move_to_end(&MoveToEnd, window, cx);
}
editor
})
}
const RPC_MESSAGES: &str = "RPC Messages";
const SERVER_LOGS: &str = "Server Logs";
const SERVER_TRACE: &str = "Server Trace";