From 53c5db449575ea43aac57e8240c3e057a6ae5159 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Fri, 12 Sep 2025 23:39:15 +0200 Subject: [PATCH] Highlight Zed log file by default if log language is available (#38091) This ensures that we highlight the log file with the log extension should the extension be installed. If it is not installed, we just fallback to the default of no highlighting, but also log no errors. Release Notes: - N/A --- crates/zed/src/zed.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 7b592cf06c06fd7e090def3db3b084024aad86cd..87664d20f0df08761ca6f5cc3a14ad59e978605f 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1112,10 +1112,15 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex const MAX_LINES: usize = 1000; workspace .with_local_workspace(window, cx, move |workspace, window, cx| { - let fs = workspace.app_state().fs.clone(); + let app_state = workspace.app_state(); + let languages = app_state.languages.clone(); + let fs = app_state.fs.clone(); cx.spawn_in(window, async move |workspace, cx| { - let (old_log, new_log) = - futures::join!(fs.load(paths::old_log_file()), fs.load(paths::log_file())); + let (old_log, new_log, log_language) = futures::join!( + fs.load(paths::old_log_file()), + fs.load(paths::log_file()), + languages.language_for_name("log") + ); let log = match (old_log, new_log) { (Err(_), Err(_)) => None, (old_log, new_log) => { @@ -1138,6 +1143,7 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex ) } }; + let log_language = log_language.ok(); workspace .update_in(cx, |workspace, window, cx| { @@ -1163,7 +1169,7 @@ fn open_log_file(workspace: &mut Workspace, window: &mut Window, cx: &mut Contex }; let project = workspace.project().clone(); let buffer = project.update(cx, |project, cx| { - project.create_local_buffer(&log, None, false, cx) + project.create_local_buffer(&log, log_language, false, cx) }); let buffer = cx