aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-01-31 03:36:36 +0000
committerBlaž Hrastnik2022-01-31 07:04:58 +0000
commitf7f55143a1c8f8f643c4ca59d8c4beb9612ef0bb (patch)
tree58760c28d47c591eeb98096358e8acbf3cafdbcd /helix-term/src/ui
parent4c996f43dfb81bc7438f2e24447c0370f1f4a97a (diff)
Improve code action picker by displaying it inline
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/picker.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 945e14bb..4068a2d4 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -393,6 +393,16 @@ fn inner_rect(area: Rect) -> Rect {
}
impl<T: 'static> Component for Picker<T> {
+ fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
+ let max_width = 50.min(viewport.0);
+ let max_height = 10.min(viewport.1.saturating_sub(2)); // add some spacing in the viewport
+
+ let height = (self.options.len() as u16 + 4) // add some spacing for input + padding
+ .min(max_height);
+ let width = max_width;
+ Some((width, height))
+ }
+
fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
let key_event = match event {
Event::Key(event) => event,