Skip to content

Commit

Permalink
Fix crash from invalid nvim_ui_pum_set_bounds args
Browse files Browse the repository at this point in the history
Fixes #112, hopefully.

My assumption here now is that because of the GTK+ bug causing the popup
menu to close pre-emptively due to popup menu ownership changes - we may
also be getting invalid coordinates when this happens, resulting in nvim
being upset. So, let's try fixing this.
  • Loading branch information
Lyude committed Oct 4, 2024
1 parent 893f98d commit e350d8b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/popup_menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ impl PopupMenu {
let (mut x, mut y, mut w, mut h) = cell_metrics
.get_fractional_grid_area((x as f64, y as f64, w as f64, h as f64));

// Double check that we're not sending it bogus coordinates, nvim will get very
// upset if we do
if w <= 0.0 || h <= 0.0 {
debug!("popupmenu bounds are bogus ({w}x{h}), ignoring");
return;
}

if x < 0.0 {
w += x;
x = 0.0;
Expand Down

0 comments on commit e350d8b

Please sign in to comment.