minad / mini-popup

24 stars 3 forks source link

Marginalia popups are getting pushed aside #1

Closed Alexander-Miller closed 3 years ago

Alexander-Miller commented 3 years ago

I've tried this package together with vertico. The height function looks very promising, but I think there is something wrong with the width:

mini1

minad commented 3 years ago

Haha interesting. I don't see this. But I have an idea what causes this - I am resizing the child frame and intend to use the same width every time, by asking the frame for its width. Now there seems to be some additional margin getting into that calculation, then the frame gets bigger every time.

Alexander-Miller commented 3 years ago

It only happens when I have a custom size function. Try this setup:

(require 'mini-popup)
(vertico-mode)
(marginalia-mode)
(mini-popup-mode)
(setf vertico-count 8)
(add-hook 'consult--completion-refresh-hook #'mini-popup--setup-hook 99)

(defun mini-popup-height-resize ()
  (* (default-line-height) 5))
(setq mini-popup--height-function #'mini-popup-height-resize)
Alexander-Miller commented 3 years ago

This seems to fix it:

modified   mini-popup.el
@@ -114,12 +114,10 @@
 (defun mini-popup--resize ()
   "Resize according to `mini-popup--height-function'."
   (when mini-popup--height-function
-    (let ((window-min-height 1)
-          (window-min-width 1))
-      (set-frame-size mini-popup--frame
-                      (frame-pixel-width mini-popup--frame)
-                      (funcall mini-popup--height-function)
-                      'pixelwise))))
+    (let ((window-min-height 1))
+      (set-frame-height mini-popup--frame
+                        (funcall mini-popup--height-function)
+                        nil 'pixelwise))))
minad commented 3 years ago

Thanks! For some reason I missed the set-frame-height function.