From f8deebc6db50fee221768e783fee28467bd56cd1 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 7 Mar 2025 13:34:37 +0200 Subject: [PATCH] Fix inline diagnostics in the project diff (#26275) https://github.com/zed-industries/zed/blob/205f9a9f0391da47a87cac45a41f67d2a23f5a95/crates/editor/src/element.rs#L1643 Due to the snippet above, Zed is supposed to have `row` larger or equal to `start_row` here: https://github.com/zed-industries/zed/blob/205f9a9f0391da47a87cac45a41f67d2a23f5a95/crates/editor/src/element.rs#L1694 yet the panic were reported when clicking in the project diff. That project diff has a lot of highlighting happening already, so the PR disables inline diagnostics within a git diff view. Release Notes: - N/A --- crates/editor/src/element.rs | 2 +- crates/git_ui/src/project_diff.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 1e3f7f2e7b0584f4e8e277fa5b126ac42b76bee1..473a98ed5000c2983a66c36361b29d5302255ac1 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1691,7 +1691,7 @@ impl EditorElement { let pos_y = content_origin.y + line_height * (row.0 as f32 - scroll_pixel_position.y / line_height); - let window_ix = row.minus(start_row) as usize; + let window_ix = row.0.saturating_sub(start_row.0) as usize; let pos_x = { let crease_trailer_layout = &crease_trailers[window_ix]; let line_layout = &line_layouts[window_ix]; diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 81fb36321bad6c75633e1d37b4b2f1f9fe540c70..a3b9591fbc6534cc46f8d8fe36c8495b61cb65b5 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -138,6 +138,7 @@ impl ProjectDiff { window, cx, ); + diff_display_editor.disable_inline_diagnostics(); diff_display_editor.set_expand_all_diff_hunks(cx); diff_display_editor.register_addon(GitPanelAddon { workspace: workspace.downgrade(),