Fix completion doc popup area calculation logic

Earlier the doc popup would draw over the compeltion popup
itself and sometimes over the cursor too.
pull/5914/head
Gokul Soumya 2 years ago committed by Blaž Hrastnik
parent 1562b5ce67
commit 425315d752

@ -453,19 +453,25 @@ impl Component for Completion {
} }
Rect::new(x, y, doc_width, doc_height) Rect::new(x, y, doc_width, doc_height)
} else { } else {
let half = area.height / 2; // Documentation should not cover the cursor or the completion popup
let doc_height = 15.min(half); // Completion popup could be above or below the current line
// we want to make sure the cursor is visible (not hidden behind the documentation) let avail_height_above = cursor_pos.min(popup_area.top()).saturating_sub(1);
let y = if cursor_pos + area.y let avail_height_below = area
>= (cx.editor.tree.area().height - doc_height - 2/* statusline + commandline */) .height
{ .saturating_sub(cursor_pos.max(popup_area.bottom()) + 1 /* padding */);
0 let (y, avail_height) = if avail_height_below >= avail_height_above {
(
area.height.saturating_sub(avail_height_below),
avail_height_below,
)
} else { } else {
// -2 to subtract command line + statusline. a bit of a hack, because of splits. (0, avail_height_above)
area.height.saturating_sub(doc_height).saturating_sub(2)
}; };
if avail_height <= 1 {
return;
}
Rect::new(0, y, area.width, doc_height) Rect::new(0, y, area.width, avail_height.min(15))
}; };
// clear area // clear area

Loading…
Cancel
Save