]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix two tooltip problems
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 15 Mar 2013 02:01:03 +0000 (06:01 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 15 Mar 2013 02:01:03 +0000 (06:01 +0400)
* company-safe-substring: take into account character composition.
* company--replacement-string: append default face everywhere, so that we never
  inherit face background from the character at the end of the overlay.

company.el

index 364440b753c1c3775f5f34c43cc6fa168ce88afa..51525cb3c8402c9540c8adc28ecc16af50aa5197 100644 (file)
@@ -75,6 +75,7 @@
 ;;    the completion keymap is active, other minor modes' keymaps are still
 ;;    used, so, for example, it's not as easy to circumvent `paredit-mode'
 ;;    accidentally when it's enabled.
+;;    Fixed two old tooltip annoyances.
 ;;
 ;; 2010-02-24 (0.5)
 ;;    `company-ropemacs' now provides location and docs.  (Fernando H. Silva)
@@ -1434,7 +1435,7 @@ To show the number next to the candidates in some back-ends, enable
     (make-string len ?\ )))
 
 (defsubst company-safe-substring (str from &optional to)
-  (let ((len (length str)))
+  (let ((len (string-width str)))
     (if (> from len)
         ""
       (if (and to (> to len))
@@ -1681,9 +1682,12 @@ Example:
     ;; Append whole new lines.
     (while lines
       (push (concat (company-space-string column) (pop lines)) new))
-    (concat (when nl "\n")
-            (mapconcat 'identity (nreverse new) "\n")
-            "\n")))
+
+    (let ((str (concat (when nl "\n")
+                       (mapconcat 'identity (nreverse new) "\n")
+                       "\n")))
+      (font-lock-append-text-property 0 (length str) 'face 'default str)
+      str)))
 
 (defun company--create-lines (selection limit)