aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/prompt.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-23 06:38:49 +0000
committerBlaž Hrastnik2021-06-23 12:55:13 +0000
commit39dc09e6c4172299bc79de4c1c52288d3f624bd7 (patch)
treeecaf882d40f4718185e428cabc885f389bb879b6 /helix-term/src/ui/prompt.rs
parent3606d8bd247c27067b987a11f20cba236d02dcaa (diff)
ui: Paginate prompt completion
Diffstat (limited to 'helix-term/src/ui/prompt.rs')
-rw-r--r--helix-term/src/ui/prompt.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index c40be1a2..63078c39 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -292,17 +292,21 @@ impl Prompt {
let area = completion_area;
let background = theme.get("ui.statusline");
+ let items = height as usize * cols as usize;
+
+ let offset = self
+ .selection
+ .map(|selection| selection / items * items)
+ .unwrap_or_default();
+
surface.clear_with(area, background);
let mut row = 0;
let mut col = 0;
// TODO: paginate
- for (i, (_range, completion)) in self
- .completion
- .iter()
- .enumerate()
- .take(height as usize * cols as usize)
+ for (i, (_range, completion)) in
+ self.completion.iter().enumerate().skip(offset).take(items)
{
let color = if Some(i) == self.selection {
// Style::default().bg(Color::Rgb(104, 60, 232))