diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index e7ba9f0fc..bf15893bd 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -980,7 +980,7 @@ pub fn hover(cx: &mut Context) { // skip if contents empty let contents = ui::Markdown::new(contents, editor.syn_loader.clone()); - let popup = Popup::new("hover", contents).auto_close(true); + let popup = Popup::new("hover", contents).auto_close(true).position(editor.cursor().0); compositor.replace_or_push("hover", popup); } }, diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs index 5362bdc7f..6b97dd20c 100644 --- a/helix-term/src/ui/popup.rs +++ b/helix-term/src/ui/popup.rs @@ -124,15 +124,10 @@ impl Popup { } fn render_info(&mut self, viewport: Rect, editor: &Editor) -> RenderInfo { - let mut position = editor.cursor().0.unwrap_or_default(); - if let Some(old_position) = self + let position = self .position - .filter(|old_position| old_position.row == position.row) - { - position = old_position; - } else { - self.position = Some(position); - } + .or_else(|| editor.cursor().0) + .unwrap_or_default(); let is_menu = self .contents