@@ -448,39 +448,42 @@ impl Component for Completion {
448448
449449 let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
450450 let (popup_width, _popup_height) = self.popup.get_size();
451− let mut width = area
451+ let doc_width_available = area
452452 .width
453453 .saturating_sub(popup_x)
454454 .saturating_sub(popup_width);
455− let area = if width > 30 {
456− let mut height = area.height.saturating_sub(popup_y);
455+ let doc_area = if doc_width_available > 30 {
456+ let mut doc_width = doc_width_available;
457+ let mut doc_height = area.height.saturating_sub(popup_y);
457458 let x = popup_x + popup_width;
458459 let y = popup_y;
459460
460− if let Some((rel_width, rel_height)) = markdown_doc.required_size((width, height)) {
461− width = rel_width.min(width);
462− height = rel_height.min(height);
461+ if let Some((rel_width, rel_height)) =
462+ markdown_doc.required_size((doc_width, doc_height))
463+ {
464+ doc_width = rel_width.min(doc_width);
465+ doc_height = rel_height.min(doc_height);
463466 }
464− Rect::new(x, y, width, height)
467+ Rect::new(x, y, doc_width, doc_height)
465468 } else {
466469 let half = area.height / 2;
467− let height = 15.min(half);
470+ let doc_height = 15.min(half);
468471 // we want to make sure the cursor is visible (not hidden behind the documentation)
469472 let y = if cursor_pos + area.y
470− >= (cx.editor.tree.area().height - height - 2/* statusline + commandline */)
473+ >= (cx.editor.tree.area().height - doc_height - 2/* statusline + commandline */)
471474 {
472475 0
473476 } else {
474477 // -2 to subtract command line + statusline. a bit of a hack, because of splits.
475− area.height.saturating_sub(height).saturating_sub(2)
478+ area.height.saturating_sub(doc_height).saturating_sub(2)
476479 };
477480
478− Rect::new(0, y, area.width, height)
481+ Rect::new(0, y, area.width, doc_height)
479482 };
480483
481484 // clear area
482485 let background = cx.editor.theme.get("ui.popup");
483− surface.clear_with(area, background);
484− markdown_doc.render(area, surface, cx);
486+ surface.clear_with(doc_area, background);
487+ markdown_doc.render(doc_area, surface, cx);
485488 }
486489}