]> code.delx.au - gnu-emacs-elpa/commitdiff
company--insert-candidate: Don't insert an empty string
authorDmitry Gutov <dgutov@yandex.ru>
Sat, 21 Mar 2015 14:30:40 +0000 (16:30 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Sat, 21 Mar 2015 14:30:40 +0000 (16:30 +0200)
Fixes #330

company.el

index 01e1d04b307ee22e3a72031b98291e00d1051542..750850b0f79f2c1367bb55ed38fdcb41061fd0c4 100644 (file)
@@ -994,13 +994,14 @@ Controlled by `company-auto-complete'.")
   (substring str (length company-prefix)))
 
 (defun company--insert-candidate (candidate)
-  (setq candidate (substring-no-properties candidate))
-  ;; XXX: Return value we check here is subject to change.
-  (if (eq (company-call-backend 'ignore-case) 'keep-prefix)
-      (insert (company-strip-prefix candidate))
-    (unless (equal company-prefix candidate)
-      (delete-region (- (point) (length company-prefix)) (point))
-      (insert candidate))))
+  (when (> (length candidate) 0)
+    (setq candidate (substring-no-properties candidate))
+    ;; XXX: Return value we check here is subject to change.
+    (if (eq (company-call-backend 'ignore-case) 'keep-prefix)
+        (insert (company-strip-prefix candidate))
+      (unless (equal company-prefix candidate)
+        (delete-region (- (point) (length company-prefix)) (point))
+        (insert candidate)))))
 
 (defmacro company-with-candidate-inserted (candidate &rest body)
   "Evaluate BODY with CANDIDATE temporarily inserted.
@@ -1922,8 +1923,7 @@ With ARG, move by that many elements."
     (if (and (not (cdr company-candidates))
              (equal company-common (car company-candidates)))
         (company-complete-selection)
-      (when company-common
-        (company--insert-candidate company-common)))))
+      (company--insert-candidate company-common))))
 
 (defun company-complete-common-or-cycle (&optional arg)
   "Insert the common part of all candidates, or select the next one.