Skip to content

Commit

Permalink
Fix issue #915 , adjust acm menu position follow icon/index option.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Apr 20, 2024
1 parent ac40260 commit 12302c7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
20 changes: 15 additions & 5 deletions acm/acm-frame.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,21 @@

(defun acm-frame-get-popup-position (frame-popup-point &optional line-bias)
(let* ((edges (window-pixel-edges))
(window-left (+ (nth 0 edges)
;; We need adjust left margin for buffer centering module.
(/ (- (window-pixel-width)
(window-body-width nil t))
2)))
(window-left (+
;; Edges fine-tuning.
(nth 0 edges)
;; Icon fine-tuning.
(if acm-enable-icon
0
(* (frame-char-width) (- acm-icon-width 1))) ; acm will add left padding 1 char when icon is disable
;; Index fine-tuning.
(if acm-enable-quick-access
(- (* (frame-char-width) 3)) ; 3 is index width
0)
;; Margin fine-tuning for centering module.
(/ (- (window-pixel-width)
(window-body-width nil t))
2)))
(window-top (nth 1 edges))
(pos (posn-x-y (posn-at-point frame-popup-point)))
(x (car pos))
Expand Down
23 changes: 13 additions & 10 deletions acm/acm.el
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ So we use `minor-mode-overriding-map-alist' to override key, make sure all keys
("org-roam"
(when (org-in-regexp org-roam-bracket-completion-re 1)
(cons (match-beginning 2)
(match-end 2))))
(match-end 2))))
("string"
(cons (point)
(save-excursion
Expand All @@ -400,9 +400,9 @@ So we use `minor-mode-overriding-map-alist' to override key, make sure all keys
(defun acm-get-input-prefix ()
"Get user input prefix."
(let* ((acm-input-bound-style (if (acm-in-roam-bracket-p)
"org-roam"
"ascii"))
(bound (acm-get-input-prefix-bound)))
"org-roam"
"ascii"))
(bound (acm-get-input-prefix-bound)))
(if bound
(buffer-substring-no-properties (car bound) (cdr bound))
"")))
Expand Down Expand Up @@ -616,10 +616,10 @@ The key of candidate will change between two LSP results."
(candidates (or candidate (acm-update-candidates)))
(menu-candidates (cl-subseq candidates 0 (min (length candidates) acm-menu-length)))
(current-select-candidate-index (cl-position previous-select-candidate (mapcar 'acm-menu-index-info menu-candidates) :test 'equal))
(acm-input-bound-style (if (acm-in-roam-bracket-p)
"org-roam"
"ascii"))
(bounds (acm-get-input-prefix-bound)))
(acm-input-bound-style (if (acm-in-roam-bracket-p)
"org-roam"
"ascii"))
(bounds (acm-get-input-prefix-bound)))
(cond
;; Hide completion menu if user type first candidate completely, except when candidate annotation is `emmet' or `snippet'.
((and (equal (length candidates) 1)
Expand Down Expand Up @@ -857,8 +857,11 @@ The key of candidate will change between two LSP results."
;; Build candidate line.
(setq candidate-line
(concat
;; Icon text.
icon-text
;; Icon.
(if acm-enable-icon
icon-text ; render icon if `acm-enable-icon' is t
" ") ; add left padding if `acm-enable-icon' is nil
;; Index.
(when acm-enable-quick-access
(if quick-access-key (concat quick-access-key ". ") " "))
;; Candidate.
Expand Down

0 comments on commit 12302c7

Please sign in to comment.