Make completion window move to top when cursor is below half
This commit is contained in:
parent
34ebe82654
commit
980e602352
@ -238,6 +238,9 @@ fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
|||||||
.language()
|
.language()
|
||||||
.and_then(|scope| scope.strip_prefix("source."))
|
.and_then(|scope| scope.strip_prefix("source."))
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
let cursor_pos = doc.selection(view.id).cursor();
|
||||||
|
let cursor_pos =
|
||||||
|
helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row - view.first_line;
|
||||||
|
|
||||||
let doc = match &option.documentation {
|
let doc = match &option.documentation {
|
||||||
Some(lsp::Documentation::String(contents))
|
Some(lsp::Documentation::String(contents))
|
||||||
@ -289,8 +292,14 @@ fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
|||||||
|
|
||||||
let half = area.height / 2;
|
let half = area.height / 2;
|
||||||
let height = 15.min(half);
|
let height = 15.min(half);
|
||||||
// -2 to subtract command line + statusline. a bit of a hack, because of splits.
|
let y = if cursor_pos > half as usize {
|
||||||
let area = Rect::new(0, area.height - height - 2, area.width, height);
|
0
|
||||||
|
} else {
|
||||||
|
// -2 to subtract command line + statusline. a bit of a hack, because of splits.
|
||||||
|
area.height.saturating_sub(height).saturating_sub(2)
|
||||||
|
};
|
||||||
|
|
||||||
|
let area = 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");
|
||||||
|
@ -162,7 +162,6 @@ fn to_span(text: pulldown_cmark::CowStr) -> Span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Code(text) | Event::Html(text) => {
|
Event::Code(text) | Event::Html(text) => {
|
||||||
log::warn!("code {:?}", text);
|
|
||||||
let mut span = to_span(text);
|
let mut span = to_span(text);
|
||||||
span.style = code_style;
|
span.style = code_style;
|
||||||
spans.push(span);
|
spans.push(span);
|
||||||
|
Loading…
Reference in New Issue
Block a user