@@ -448,39 +448,42 @@ impl Component for Completion {
449 let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
449 let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
450 let (popup_width, _popup_height) = self.popup.get_size();
450 let (popup_width, _popup_height) = self.popup.get_size();
451− let mut width = area
451+ let doc_width_available = area
453 .saturating_sub(popup_x)
453 .saturating_sub(popup_x)
454 .saturating_sub(popup_width);
454 .saturating_sub(popup_width);
455− let area = if width > 30 {
455+ let doc_area = if doc_width_available > 30 {
456+ let mut doc_width = doc_width_available;
456− let mut height = area.height.saturating_sub(popup_y);
457+ let mut doc_height = area.height.saturating_sub(popup_y);
457 let x = popup_x + popup_width;
458 let x = popup_x + popup_width;
458 let y = popup_y;
459 let y = popup_y;
460− if let Some((rel_width, rel_height)) = markdown_doc.required_size((width, height)) {
461+ if let Some((rel_width, rel_height)) =
462+ markdown_doc.required_size((doc_width, doc_height))
461− width = rel_width.min(width);
464+ doc_width = rel_width.min(doc_width);
462− height = rel_height.min(height);
465+ doc_height = rel_height.min(doc_height);
464− Rect::new(x, y, width, height)
467+ Rect::new(x, y, doc_width, doc_height)
466 let half = area.height / 2;
469 let half = area.height / 2;
467− let height = 15.min(half);
470+ let doc_height = 15.min(half);
468 // we want to make sure the cursor is visible (not hidden behind the documentation)
471 // we want to make sure the cursor is visible (not hidden behind the documentation)
469 let y = if cursor_pos + area.y
472 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 */)
474 // -2 to subtract command line + statusline. a bit of a hack, because of splits.
477 // -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)
478− Rect::new(0, y, area.width, height)
481+ Rect::new(0, y, area.width, doc_height)
481 // clear area
484 // clear area
482 let background = cx.editor.theme.get("ui.popup");
485 let background = cx.editor.theme.get("ui.popup");
483− surface.clear_with(area, background);
486+ surface.clear_with(doc_area, background);
484− markdown_doc.render(area, surface, cx);
487+ markdown_doc.render(doc_area, surface, cx);