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 ba94085 commit 8c4b834
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 @@ -407,6 +407,13 @@ impl PopupMenu {
(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 8c4b834

Please sign in to comment.