Skip to content

Commit 7b638a2

Browse files
Anthony-Eidtomatitito
authored andcommitted
editor: Fix calculate relative line number panic (zed-industries#41352)
### Reproduction steps 1. Turn on relative line numbers 2. Start a debugging session and hit an active debug line 3. minimize Zed so the editor element with the active debug line has zero visible rows #### Before https://github.com/user-attachments/assets/57cc7a4d-478d-481a-8b70-f14c879bd858 #### After https://github.com/user-attachments/assets/19614104-f9aa-4b76-886b-1ad4a5985403 Release Notes: - debugger: Fix a panic that could occur when minimizing Zed
1 parent 04a3daf commit 7b638a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/editor/src/element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,7 @@ impl EditorElement {
31813181
i += 1;
31823182
}
31833183
delta = 1;
3184-
i = head_idx.min(buffer_rows.len() as u32 - 1);
3184+
i = head_idx.min(buffer_rows.len().saturating_sub(1) as u32);
31853185
while i > 0 && buffer_rows[i as usize].buffer_row.is_none() && !count_wrapped_lines {
31863186
i -= 1;
31873187
}

0 commit comments

Comments
 (0)