[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 5956a34: Add option company-abort-on-unique-mat
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 5956a34: Add option company-abort-on-unique-match |
Date: |
Sat, 2 Jan 2021 15:57:06 -0500 (EST) |
branch: externals/company
commit 5956a34587794cef3c46cb19e2ff45f7edbef5e8
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Add option company-abort-on-unique-match
Closes #1046
---
NEWS.md | 2 ++
company.el | 13 ++++++++++++-
test/core-tests.el | 15 +++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index 7801b22..30f979c 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
## Next
+* New user option `company-abort-on-unique-match`
+ ([#1046](https://github.com/company-mode/company-mode/issues/1046)).
* `company-select-mouse` is a new frontend action
([#1045](https://github.com/company-mode/company-mode/pull/1045)).
* `company-gtags` on remote hosts is improved
diff --git a/company.el b/company.el
index 37ccac8..d352e3f 100644
--- a/company.el
+++ b/company.el
@@ -543,6 +543,16 @@ prefix it was started from."
:type 'boolean
:package-version '(company . "0.8.0"))
+(defcustom company-abort-on-unique-match t
+ "If non-nil, typing a full unique match aborts completion.
+
+You can still invoke `company-complete' manually to run the
+`post-completion' handler, though.
+
+If it's nil, completion will remain active until you type a prefix that
+doesn't match anything or finish it manually, e.g. with RET."
+ :type 'boolean)
+
(defcustom company-require-match 'company-explicit-action-p
"If enabled, disallow non-matching input.
This can be a function do determine if a match is required.
@@ -1637,7 +1647,8 @@ prefix match (same case) will be prioritized."
company-backend backend
c (company-calculate-candidates company-prefix ignore-case))
(cond
- ((and (company--unique-match-p c company-prefix ignore-case)
+ ((and company-abort-on-unique-match
+ (company--unique-match-p c company-prefix ignore-case)
(if company--manual-action
;; If `company-manual-begin' was called, the user
;; really wants something to happen. Otherwise...
diff --git a/test/core-tests.el b/test/core-tests.el
index 5b8b9d4..279b784 100644
--- a/test/core-tests.el
+++ b/test/core-tests.el
@@ -53,6 +53,7 @@
(insert "abc")
(company-mode)
(let (company-frontends
+ (company-abort-on-unique-match t)
(company-backends
(list (lambda (command &optional _)
(cl-case command
@@ -61,6 +62,20 @@
(company-auto-begin)
(should (equal nil company-candidates)))))
+(ert-deftest company-auto-begin-unique-cancels-not ()
+ (with-temp-buffer
+ (insert "abc")
+ (company-mode)
+ (let (company-frontends
+ company-abort-on-unique-match
+ (company-backends
+ (list (lambda (command &optional _)
+ (cl-case command
+ (prefix (buffer-substring (point-min) (point)))
+ (candidates '("abc")))))))
+ (company-auto-begin)
+ (should (equal '("abc") company-candidates)))))
+
(ert-deftest company-manual-begin-unique-shows-completion ()
(with-temp-buffer
(insert "abc")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/company 5956a34: Add option company-abort-on-unique-match,
ELPA Syncer <=