aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwojciechkepka2021-06-20 05:15:08 +0000
committerBlaž Hrastnik2021-06-20 10:59:26 +0000
commit0882712b4598586ce7c9b8e8f446d6a6fc5ff060 (patch)
treed0ec62d1d726ed3a377e3d1914a6cf9b0bdd0b0a
parent980e6023523119676652b49692eb5f844d84d703 (diff)
Use full screen size
-rw-r--r--helix-term/src/ui/completion.rs8
-rw-r--r--helix-view/src/tree.rs4
2 files changed, 9 insertions, 3 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index f4d882de..256d8f7d 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -239,8 +239,8 @@ impl Component for Completion {
.and_then(|scope| scope.strip_prefix("source."))
.unwrap_or("");
let cursor_pos = doc.selection(view.id).cursor();
- let cursor_pos =
- helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row - view.first_line;
+ let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row
+ - view.first_line) as u16;
let doc = match &option.documentation {
Some(lsp::Documentation::String(contents))
@@ -292,7 +292,9 @@ impl Component for Completion {
let half = area.height / 2;
let height = 15.min(half);
- let y = if cursor_pos > half as usize {
+ let y = if cursor_pos + view.area.y
+ >= (cx.editor.tree.area().height - height - 1/* statusline */)
+ {
0
} else {
// -2 to subtract command line + statusline. a bit of a hack, because of splits.
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index a0c466d9..f7d6c1f2 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -434,6 +434,10 @@ impl Tree {
self.focus = key;
}
}
+
+ pub fn area(&self) -> Rect {
+ self.area
+ }
}
#[derive(Debug)]