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

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

[elpa] master b94b115 025/173: company--insert-candidate: Don't insert a


From: Dmitry Gutov
Subject: [elpa] master b94b115 025/173: company--insert-candidate: Don't insert an empty string
Date: Thu, 23 Jun 2016 00:28:35 +0000 (UTC)

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

    company--insert-candidate: Don't insert an empty string
    
    Fixes #330
---
 company.el |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/company.el b/company.el
index 01e1d04..750850b 100644
--- a/company.el
+++ b/company.el
@@ -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.



reply via email to

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