on master help sign in
Make completion window move to top when cursor is below half
980e602wojciechkepka
helix-term/src/ui/completion.rs+11−2
@@ -238,6 +238,9 @@ impl Component for Completion {
238 .language()
238 .language()
239 .and_then(|scope| scope.strip_prefix("source."))
239 .and_then(|scope| scope.strip_prefix("source."))
240 .unwrap_or("");
240 .unwrap_or("");
241+ let cursor_pos = doc.selection(view.id).cursor();
242+ let cursor_pos =
243+ helix_core::coords_at_pos(doc.text().slice(..), cursor_pos).row - view.first_line;
241
244
242 let doc = match &option.documentation {
245 let doc = match &option.documentation {
243 Some(lsp::Documentation::String(contents))
246 Some(lsp::Documentation::String(contents))
@@ -289,8 +292,14 @@ impl Component for Completion {
289
292
290 let half = area.height / 2;
293 let half = area.height / 2;
291 let height = 15.min(half);
294 let height = 15.min(half);
295+ let y = if cursor_pos > half as usize {
296+ 0
297+ } else {
292− // -2 to subtract command line + statusline. a bit of a hack, because of splits.
298+ // -2 to subtract command line + statusline. a bit of a hack, because of splits.
299+ area.height.saturating_sub(height).saturating_sub(2)
300+ };
301+
293− let area = Rect::new(0, area.height - height - 2, area.width, height);
302+ let area = Rect::new(0, y, area.width, height);
294
303
295 // clear area
304 // clear area
296 let background = cx.editor.theme.get("ui.popup");
305 let background = cx.editor.theme.get("ui.popup");
helix-term/src/ui/markdown.rs−1
@@ -162,7 +162,6 @@ fn parse<'a>(
162 }
162 }
163 }
163 }
164 Event::Code(text) | Event::Html(text) => {
164 Event::Code(text) | Event::Html(text) => {
165− log::warn!("code {:?}", text);
166 let mut span = to_span(text);
165 let mut span = to_span(text);
167 span.style = code_style;
166 span.style = code_style;
168 spans.push(span);
167 spans.push(span);