branch: externals/company
commit b4651aed57e23b49dc43686c48e471c9d6d263ed
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
company-childframe-show-at-prefix: Adjust for after-string overlays, if any
In particular, created by minibuffer-message by company-echo-show in
pre-command.
---
company-childframe.el | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/company-childframe.el b/company-childframe.el
index 31a8e237c0..3f1efa0094 100644
--- a/company-childframe.el
+++ b/company-childframe.el
@@ -88,17 +88,28 @@ Users of HiDPI screens might like to set it to 2."
(defun company-childframe-show-at-prefix (info)
"Poshandler showing `company-childframe' at `company-prefix'."
(let* ((parent-window (plist-get info :parent-window))
- (point (with-current-buffer (window-buffer parent-window)
- (- (plist-get info :position)
- (plist-get info :company-prefix-length))))
+ (point (- (plist-get info :position)
+ (plist-get info :company-prefix-length)))
+ (after-string-width
+ (with-current-buffer (window-buffer parent-window)
+ (thread-last
+ (and (= point (point-max))
+ (overlays-in point point))
+ (mapcar (lambda (o) (string-pixel-width
+ (overlay-get o 'after-string))))
+ (cl-reduce #'+))))
(posn (posn-at-point point parent-window))
;; TODO: Strictly speaking, if company-childframe-font is not nil,
that
;; should be used to find the default width...
(expected-margin-width (* (plist-get info :company-margin)
(default-font-width)))
(xy (posn-x-y posn)))
- (setcar xy (- (car xy) expected-margin-width (if (display-graphic-p)
-
company-childframe-border-width
- 0)))
+ (setcar xy (- (car xy) expected-margin-width
+ (if (display-graphic-p)
+ company-childframe-border-width
+ 0)
+ ;; Might bite us if the posn-at-point behavior changes
+ ;; someday, but the odds seem low.
+ after-string-width))
(posframe-poshandler-point-bottom-left-corner (plist-put info :position
posn))))
(defun company-childframe-show ()