Skip to content

Commit

Permalink
Adjust position when cursor in minibuffer, and make sure acm menu adj…
Browse files Browse the repository at this point in the history
…ust position after resizing.
  • Loading branch information
manateelazycat committed Jul 11, 2023
1 parent f13ee5c commit f5adc8a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions acm/acm.el
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,16 @@ The key of candidate will change between two LSP results."
(acm-frame-x (if (> (+ cursor-x acm-frame-width) emacs-width)
(max (- cursor-x acm-frame-width) offset-x)
(max (- cursor-x offset-x) 0)))
(acm-frame-y (if (> (+ cursor-y acm-frame-height) emacs-height)
(- cursor-y acm-frame-height)
(+ cursor-y offset-y))))
(acm-frame-y (cond
;; Always popup up when cursor in minibuffer.
((minibufferp)
(- (nth 1 (window-pixel-edges (minibuffer-window))) acm-frame-height))
;; Popup up when acm menu bottom below at Emacs bottom edge.
((> (+ cursor-y acm-frame-height) emacs-height)
(- cursor-y acm-frame-height))
;; Otherwise, popup down.
(t
(+ cursor-y offset-y)))))
(acm-frame-set-frame-position acm-menu-frame acm-frame-x acm-frame-y)))

(defun acm-doc-try-show (&optional update-completion-item)
Expand Down Expand Up @@ -917,9 +924,6 @@ The key of candidate will change between two LSP results."
(erase-buffer)
(acm-menu-render-items items menu-index))

;; Adjust menu frame position.
(acm-menu-adjust-pos)

;; Not adjust menu frame size if not necessary,
;; such as select candidate just change index,
;; or menu width not change when switch to next page.
Expand All @@ -931,6 +935,10 @@ The key of candidate will change between two LSP results."
(when (acm-frame-visible-p acm-doc-frame)
(acm-doc-frame-adjust)))

;; Adjust menu frame position.
;; We need adjust acm menu position after set it size, avoid coordinate shifts due to resizing.
(acm-menu-adjust-pos)

;; Fetch `documentation' and `additionalTextEdits' information.
(acm-doc-try-show)
))
Expand Down

0 comments on commit f5adc8a

Please sign in to comment.