[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3806d21 1/2: Fix small bug in 'completion-table-subvert'.
From: |
Philipp Stephani |
Subject: |
master 3806d21 1/2: Fix small bug in 'completion-table-subvert'. |
Date: |
Fri, 23 Apr 2021 07:03:07 -0400 (EDT) |
branch: master
commit 3806d2168bdc36796d2dfac5f743582f0ce71c72
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>
Fix small bug in 'completion-table-subvert'.
Even for a trivial underlying completion table (where the 'boundaries'
action returns nil), we need to provide nontrivial boundaries so that
they match the behavior of 'all-completions'.
* lisp/minibuffer.el (completion-table-subvert): Return boundaries
even for trivial underlying completion table.
* test/lisp/minibuffer-tests.el (completion-table-subvert-test):
Amend unit test to also test boundaries. While there, also test
the other completion functions.
---
lisp/minibuffer.el | 2 +-
test/lisp/minibuffer-tests.el | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 7da3c39..51e0519 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -271,7 +271,7 @@ the form (concat S2 S)."
(let* ((str (if (string-prefix-p s1 string completion-ignore-case)
(concat s2 (substring string (length s1)))))
(res (if str (complete-with-action action table str pred))))
- (when res
+ (when (or res (eq (car-safe action) 'boundaries))
(cond
((eq (car-safe action) 'boundaries)
(let ((beg (or (and (eq (car-safe res) 'boundaries) (cadr res)) 0)))
diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el
index 791e51c..027711c 100644
--- a/test/lisp/minibuffer-tests.el
+++ b/test/lisp/minibuffer-tests.el
@@ -83,7 +83,12 @@
(let* ((origtable '("A-hello" "A-there"))
(subvtable (completion-table-subvert origtable "B" "A")))
(should (equal (try-completion "B-hel" subvtable)
- "B-hello"))))
+ "B-hello"))
+ (should (equal (all-completions "B-hel" subvtable) '("-hello")))
+ (should (test-completion "B-hello" subvtable))
+ (should (equal (completion-boundaries "B-hel" subvtable
+ nil "suffix")
+ '(1 . 6)))))
(ert-deftest completion-table-test-quoting ()
(let ((process-environment