]> rtime.felk.cvut.cz Git - sojka/company-mode.git/commitdiff
Prevent accidental auto-insert when moving point.
authorNikolaj Schumacher <git@nschum.de>
Thu, 16 Apr 2009 11:30:59 +0000 (13:30 +0200)
committerNikolaj Schumacher <git@nschum.de>
Sat, 18 Apr 2009 09:47:07 +0000 (11:47 +0200)
company.el

index adb0d46116838748063a0906c1a03c9172f79915..74dca39dab6bca154e0399fbd909ddea55517913 100644 (file)
@@ -757,34 +757,34 @@ keymap during active completions (`company-active-map'):
     ;; Don't complete existing candidates, fetch new ones.
     (setq company-candidates-cache nil))
   (let ((new-prefix (company-call-backend 'prefix)))
-    (unless (and (= (- (point) (length new-prefix))
-                    (- company-point (length company-prefix)))
-                 (or (equal company-prefix new-prefix)
-                     (let ((c (company-calculate-candidates new-prefix)))
-                       ;; t means complete/unique.
-                       (if (eq c t)
-                           (progn (company-cancel new-prefix) t)
-                         (when (consp c)
-                           (setq company-prefix new-prefix)
-                           (company-update-candidates c)
-                           t)))))
-      (if (company-auto-complete-p company-point (point))
-          (save-excursion
-            (goto-char company-point)
-            (company-complete-selection)
-            (setq company-candidates nil))
-        (if (not (and (company-incremental-p company-prefix new-prefix)
-                      (company-require-match-p)))
-            (progn
-              (when (equal company-prefix (car company-candidates))
-                ;; cancel, but last input was actually success
-                (company-cancel company-prefix))
-              (setq company-candidates nil))
-          (backward-delete-char (length new-prefix))
-          (insert company-prefix)
-          (ding)
-          (message "Matching input is required")))
-      company-candidates)))
+    (if (= (- (point) (length new-prefix))
+           (- company-point (length company-prefix)))
+        (unless (or (equal company-prefix new-prefix)
+                    (let ((c (company-calculate-candidates new-prefix)))
+                      ;; t means complete/unique.
+                      (if (eq c t)
+                          (progn (company-cancel new-prefix) t)
+                        (when (consp c)
+                          (setq company-prefix new-prefix)
+                          (company-update-candidates c)
+                          t))))
+          (if (not (and (company-incremental-p company-prefix new-prefix)
+                        (company-require-match-p)))
+              (progn
+                (when (equal company-prefix (car company-candidates))
+                  ;; cancel, but last input was actually success
+                  (company-cancel company-prefix))
+                (setq company-candidates nil))
+            (backward-delete-char (length new-prefix))
+            (insert company-prefix)
+            (ding)
+            (message "Matching input is required")))
+      (when (company-auto-complete-p company-point (point))
+        (save-excursion
+          (goto-char company-point)
+          (company-complete-selection)))
+      (setq company-candidates nil))
+    company-candidates))
 
 (defun company-begin ()
   (when (and (not (and company-candidates (company-continue)))