|
|
@ -262,8 +262,7 @@ impl Component for Completion {
|
|
|
|
.cursor(doc.text().slice(..));
|
|
|
|
.cursor(doc.text().slice(..));
|
|
|
|
let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row
|
|
|
|
let cursor_pos = (helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row
|
|
|
|
- view.offset.row) as u16;
|
|
|
|
- view.offset.row) as u16;
|
|
|
|
|
|
|
|
let mut markdown_doc = match &option.documentation {
|
|
|
|
let mut doc = match &option.documentation {
|
|
|
|
|
|
|
|
Some(lsp::Documentation::String(contents))
|
|
|
|
Some(lsp::Documentation::String(contents))
|
|
|
|
| Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
|
|
|
|
| Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
|
|
|
|
kind: lsp::MarkupKind::PlainText,
|
|
|
|
kind: lsp::MarkupKind::PlainText,
|
|
|
@ -311,6 +310,23 @@ impl Component for Completion {
|
|
|
|
None => return,
|
|
|
|
None => return,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let (popup_x, popup_y) = self.popup.get_rel_position(area, cx);
|
|
|
|
|
|
|
|
let (popup_width, _popup_height) = self.popup.get_size();
|
|
|
|
|
|
|
|
let mut width = area
|
|
|
|
|
|
|
|
.width
|
|
|
|
|
|
|
|
.saturating_sub(popup_x)
|
|
|
|
|
|
|
|
.saturating_sub(popup_width);
|
|
|
|
|
|
|
|
let area = if width > 30 {
|
|
|
|
|
|
|
|
let mut height = area.height.saturating_sub(popup_y);
|
|
|
|
|
|
|
|
let x = popup_x + popup_width;
|
|
|
|
|
|
|
|
let y = popup_y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some((rel_width, rel_height)) = markdown_doc.required_size((width, height)) {
|
|
|
|
|
|
|
|
width = rel_width;
|
|
|
|
|
|
|
|
height = rel_height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect::new(x, y, width, height)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
let half = area.height / 2;
|
|
|
|
let half = area.height / 2;
|
|
|
|
let height = 15.min(half);
|
|
|
|
let height = 15.min(half);
|
|
|
|
// we want to make sure the cursor is visible (not hidden behind the documentation)
|
|
|
|
// we want to make sure the cursor is visible (not hidden behind the documentation)
|
|
|
@ -323,12 +339,13 @@ impl Component for Completion {
|
|
|
|
area.height.saturating_sub(height).saturating_sub(2)
|
|
|
|
area.height.saturating_sub(height).saturating_sub(2)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let area = Rect::new(0, y, area.width, height);
|
|
|
|
Rect::new(0, y, area.width, height)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// clear area
|
|
|
|
// clear area
|
|
|
|
let background = cx.editor.theme.get("ui.popup");
|
|
|
|
let background = cx.editor.theme.get("ui.popup");
|
|
|
|
surface.clear_with(area, background);
|
|
|
|
surface.clear_with(area, background);
|
|
|
|
doc.render(area, surface, cx);
|
|
|
|
markdown_doc.render(area, surface, cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|