]> code.delx.au - gnu-emacs-elpa/commitdiff
company-pseudo-tooltip-edit: update company-width
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 13 Jun 2014 15:50:27 +0000 (18:50 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 13 Jun 2014 15:50:40 +0000 (18:50 +0300)
#138

company-tests.el
company.el

index c4e4668fb74289ca464620f27731d6954e79acc6..ea77b6104beb75e89a48890ca230772c7da55f73 100644 (file)
         (should (string= (overlay-get ov 'company-after)
                          "  123 \nc 45  c\nddd\n")))))))
 
+(ert-deftest company-pseudo-tooltip-edit-updates-width ()
+  :tags '(interactive)
+  (with-temp-buffer
+    (set-window-buffer nil (current-buffer))
+    (let ((company-candidates-length 5)
+          (company-candidates '("123" "45" "67" "89" "1011"))
+          (company-backend 'ignore)
+          (company-tooltip-limit 4)
+          (company-tooltip-offset-display 'scrollbar))
+      (company-pseudo-tooltip-show (company--row)
+                                   (company--column)
+                                   0)
+      (should (eq (overlay-get company-pseudo-tooltip-overlay 'company-width)
+                  6))
+      (company-pseudo-tooltip-edit 4)
+      (should (eq (overlay-get company-pseudo-tooltip-overlay 'company-width)
+                  7)))))
+
 (ert-deftest company-preview-show-with-annotations ()
   :tags '(interactive)
   (with-temp-buffer
index 3e345191a04d981fec615435dec2d2c6cb50ca1d..c8101004cec798c6874ff096f93bc0d73dd7c9ab 100644 (file)
@@ -2340,10 +2340,13 @@ Returns a negative number if the tooltip should be displayed above point."
     (company-pseudo-tooltip-show (1+ row) col company-selection)))
 
 (defun company-pseudo-tooltip-edit (selection)
-  (let ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)))
+  (let* ((height (overlay-get company-pseudo-tooltip-overlay 'company-height))
+         (lines  (company--create-lines selection (abs height))))
+    (overlay-put company-pseudo-tooltip-overlay 'company-width
+                 (string-width (car lines)))
     (overlay-put company-pseudo-tooltip-overlay 'company-after
                  (apply 'company--replacement-string
-                        (company--create-lines selection (abs height))
+                        lines
                         (overlay-get company-pseudo-tooltip-overlay
                                      'company-replacement-args)))))