diff options
author | Blaž Hrastnik | 2021-03-01 05:23:10 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-01 05:23:10 +0000 |
commit | 00808afe3c215d159574b23e30326379428060bf (patch) | |
tree | b9f4fdb9cf559e95340a625c7741e9dbcd31b41b /helix-term/src/commands.rs | |
parent | 2c9b02039bac81cb32309bd0d4e2b08191356b9c (diff) |
ui: Make editor more resilient about being shrunk too small.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 07e71a70..855a12eb 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1072,9 +1072,10 @@ pub fn completion(cx: &mut Context) { cx.callback = Some(Box::new( move |compositor: &mut Compositor, editor: &mut Editor| { let area = tui::layout::Rect::default(); // TODO: unused remove from cursor_position - let mut pos = compositor.cursor_position(area, editor); - pos.row += 1; // shift down by one row - menu.set_position(pos); + if let Some(mut pos) = compositor.cursor_position(area, editor) { + pos.row += 1; // shift down by one row + menu.set_position(pos); + }; compositor.push(Box::new(menu)); }, @@ -1133,9 +1134,10 @@ pub fn hover(cx: &mut Context) { cx.callback = Some(Box::new( move |compositor: &mut Compositor, editor: &mut Editor| { let area = tui::layout::Rect::default(); // TODO: unused remove from cursor_position - let mut pos = compositor.cursor_position(area, editor); - pos.row += 1; // shift down by one row - popup.set_position(pos); + if let Some(mut pos) = compositor.cursor_position(area, editor) { + pos.row += 1; // shift down by one row + popup.set_position(pos); + }; compositor.push(Box::new(popup)); }, |