editor: Log error instead of panic on index out of bounds for line layouts (#32953)
Closes #30191 `line_ix` should never exceed the bounds of `line_layouts`, but a panic happens on out-of-bounds for this, which seems weird. I couldn’t reproduce this panic at all. Since this is for displaying inline blame, we now log an error if this occurs instead of panicking. Release Notes: - N/A
This commit is contained in:
parent
48491fa487
commit
aa9dacad28
1 changed files with 30 additions and 19 deletions
|
@ -8506,26 +8506,37 @@ impl Element for EditorElement {
|
|||
);
|
||||
|
||||
let line_ix = display_row.minus(start_row) as usize;
|
||||
let row_info = &row_infos[line_ix];
|
||||
let line_layout = &line_layouts[line_ix];
|
||||
let crease_trailer_layout = crease_trailers[line_ix].as_ref();
|
||||
|
||||
if let Some(layout) = self.layout_inline_blame(
|
||||
display_row,
|
||||
row_info,
|
||||
line_layout,
|
||||
crease_trailer_layout,
|
||||
em_width,
|
||||
content_origin,
|
||||
scroll_pixel_position,
|
||||
line_height,
|
||||
&text_hitbox,
|
||||
window,
|
||||
cx,
|
||||
if let (Some(row_info), Some(line_layout), Some(crease_trailer)) = (
|
||||
row_infos.get(line_ix),
|
||||
line_layouts.get(line_ix),
|
||||
crease_trailers.get(line_ix),
|
||||
) {
|
||||
inline_blame_layout = Some(layout);
|
||||
// Blame overrides inline diagnostics
|
||||
inline_diagnostics.remove(&display_row);
|
||||
let crease_trailer_layout = crease_trailer.as_ref();
|
||||
if let Some(layout) = self.layout_inline_blame(
|
||||
display_row,
|
||||
row_info,
|
||||
line_layout,
|
||||
crease_trailer_layout,
|
||||
em_width,
|
||||
content_origin,
|
||||
scroll_pixel_position,
|
||||
line_height,
|
||||
&text_hitbox,
|
||||
window,
|
||||
cx,
|
||||
) {
|
||||
inline_blame_layout = Some(layout);
|
||||
// Blame overrides inline diagnostics
|
||||
inline_diagnostics.remove(&display_row);
|
||||
}
|
||||
} else {
|
||||
log::error!(
|
||||
"bug: line_ix {} is out of bounds - row_infos.len(): {}, line_layouts.len(): {}, crease_trailers.len(): {}",
|
||||
line_ix,
|
||||
row_infos.len(),
|
||||
line_layouts.len(),
|
||||
crease_trailers.len(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue