@@ -239,8 +239,8 @@ impl Component for Completion {
239239 .and_then(|scope| scope.strip_prefix("source."))
240240 .unwrap_or("");
241241 let cursor_pos = doc.selection(view.id).cursor();
242− let cursor_pos =
243− helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row - view.first_line;
242+ let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row
243+ - view.first_line) as u16;
244244
245245 let doc = match &option.documentation {
246246 Some(lsp::Documentation::String(contents))
@@ -292,7 +292,9 @@ impl Component for Completion {
292292
293293 let half = area.height / 2;
294294 let height = 15.min(half);
295− let y = if cursor_pos > half as usize {
295+ let y = if cursor_pos + view.area.y
296+ >= (cx.editor.tree.area().height - height - 1/* statusline */)
297+ {
296298 0
297299 } else {
298300 // -2 to subtract command line + statusline. a bit of a hack, because of splits.