[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a5289c5 03/12: Fix backspacing into a "bad" prefix
From: |
Dmitry Gutov |
Subject: |
[elpa] master a5289c5 03/12: Fix backspacing into a "bad" prefix |
Date: |
Sat, 15 Jul 2017 13:36:44 -0400 (EDT) |
branch: master
commit a5289c533c7a5445b2add25b7bf784cfa0f1f23c
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Fix backspacing into a "bad" prefix
Fixes #667.
---
company.el | 5 +++--
test/core-tests.el | 23 ++++++++++++++++++++---
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/company.el b/company.el
index 153b1f5..fbf0315 100644
--- a/company.el
+++ b/company.el
@@ -1509,8 +1509,9 @@ prefix match (same case) will be prioritized."
(setq company-prefix new-prefix)
(company-update-candidates c)
c)
- ((company-auto-complete-p (buffer-substring-no-properties
- (point) company-point))
+ ((and (> (point) company-point)
+ (company-auto-complete-p (buffer-substring-no-properties
+ (point) company-point)))
;; auto-complete
(save-excursion
(goto-char company-point)
diff --git a/test/core-tests.el b/test/core-tests.el
index 977f1cf..6c846d2 100644
--- a/test/core-tests.el
+++ b/test/core-tests.el
@@ -157,16 +157,16 @@
(let ((one (lambda (command &optional _)
(cl-case command
(prefix "a")
- (candidates '("aa" "ca" "ba")))))
+ (candidates (list "aa" "ca" "ba")))))
(two (lambda (command &optional _)
(cl-case command
(prefix "a")
- (candidates '("bb" "ab")))))
+ (candidates (list "bb" "ab")))))
(tri (lambda (command &optional _)
(cl-case command
(prefix "a")
(sorted t)
- (candidates '("cc" "bc" "ac"))))))
+ (candidates (list "cc" "bc" "ac"))))))
(let ((company-backend (list one two tri :separate)))
(should (company-call-backend 'sorted))
(should-not (company-call-backend 'duplicates))
@@ -315,6 +315,23 @@
(company-call 'backward-delete-char 1)
(should (eq 2 company-candidates-length))))))
+(ert-deftest company-backspace-into-bad-prefix ()
+ (with-temp-buffer
+ (insert "ab")
+ (company-mode)
+ (let (company-frontends
+ (company-minimum-prefix-length 2)
+ (company-backends
+ (list (lambda (command &optional _)
+ (cl-case command
+ (prefix (buffer-substring (point-min) (point)))
+ (candidates '("abcd" "abef")))))))
+ (let ((company-idle-delay 'now))
+ (company-auto-begin))
+ (company-call 'backward-delete-char-untabify 1)
+ (should (string= "a" (buffer-string)))
+ (should (null company-candidates)))))
+
(ert-deftest company-auto-complete-explicit ()
(with-temp-buffer
(insert "ab")
- [elpa] master updated (e9faca6 -> 89bd25a), Dmitry Gutov, 2017/07/15
- [elpa] master 950c547 04/12: Be more accurate about when to return `stop', Dmitry Gutov, 2017/07/15
- [elpa] master 1fe2634 02/12: Fix #665 quick and dirty, Dmitry Gutov, 2017/07/15
- [elpa] master a5289c5 03/12: Fix backspacing into a "bad" prefix,
Dmitry Gutov <=
- [elpa] master 9dbabd1 08/12: company-diag: Output major mode as well, Dmitry Gutov, 2017/07/15
- [elpa] master 4184494 10/12: Update NEWS, Dmitry Gutov, 2017/07/15
- [elpa] master a557460 05/12: Set company-template-nav-map as parent of company-template-field-map, Dmitry Gutov, 2017/07/15
- [elpa] master 6d80e9f 09/12: company--col-row: Disable native line numbers temporarily, Dmitry Gutov, 2017/07/15
- [elpa] master a43f944 06/12: Merge pull request #674 from ptrv/fix-company-template-field-keymap, Dmitry Gutov, 2017/07/15
- [elpa] master 6d05ca5 07/12: Remove dead code, Dmitry Gutov, 2017/07/15
- [elpa] master b753952 01/12: Add function and binding to clear template field and move to next (#660), Dmitry Gutov, 2017/07/15
- [elpa] master 89bd25a 12/12: Merge commit 'a197b072dc93dbad238f1dc70da01e3775ebfb56' from company, Dmitry Gutov, 2017/07/15
- [elpa] master a197b07 11/12: Release 0.9.4, Dmitry Gutov, 2017/07/15