emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 8d4ba7a 38/66: company-preview-show-at-point: Handle the p


From: Dmitry Gutov
Subject: [elpa] master 8d4ba7a 38/66: company-preview-show-at-point: Handle the pseudo-tooltip-overlay
Date: Tue, 13 Jan 2015 02:44:57 +0000

branch: master
commit 8d4ba7adac3d0358f0a0590243268585a79edd48
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    company-preview-show-at-point: Handle the pseudo-tooltip-overlay
    
    Or rather, rendering at its beginning.
    
    Fixes #267
---
 company.el |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/company.el b/company.el
index efe3c32..e8ce966 100644
--- a/company.el
+++ b/company.el
@@ -2528,8 +2528,6 @@ Returns a negative number if the tooltip should be 
displayed above point."
 (defun company-preview-show-at-point (pos)
   (company-preview-hide)
 
-  (setq company-preview-overlay (make-overlay pos pos))
-
   (let ((completion (nth company-selection company-candidates)))
     (setq completion (propertize completion 'face 'company-preview))
     (add-text-properties 0 (length company-common)
@@ -2547,11 +2545,25 @@ Returns a negative number if the tooltip should be 
displayed above point."
 
     (and (equal pos (point))
          (not (equal completion ""))
-         (add-text-properties 0 1 '(cursor t) completion))
-
-    (let ((ov company-preview-overlay))
-      (overlay-put ov 'after-string completion)
-      (overlay-put ov 'window (selected-window)))))
+         (add-text-properties 0 1 '(cursor 1) completion))
+
+    (let ((beg pos)
+          (ptf-workaround (and
+                           company-pseudo-tooltip-overlay
+                           (char-before pos)
+                           (eq ?\n (char-after pos)))))
+      ;; Try to accomodate for the pseudo-tooltip overlay,
+      ;; which may start at the same position if it's at eol.
+      (when ptf-workaround
+        (cl-decf beg)
+        (setq completion (concat (buffer-substring beg pos) completion)))
+
+      (setq company-preview-overlay (make-overlay beg pos))
+
+      (let ((ov company-preview-overlay))
+        (overlay-put ov (if ptf-workaround 'display 'after-string)
+                     completion)
+        (overlay-put ov 'window (selected-window))))))
 
 (defun company-preview-hide ()
   (when company-preview-overlay



reply via email to

[Prev in Thread] Current Thread [Next in Thread]