[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f2019fc: Fix case-insensitive completion of buffer names
From: |
Eli Zaretskii |
Subject: |
master f2019fc: Fix case-insensitive completion of buffer names |
Date: |
Sat, 9 Nov 2019 14:57:20 -0500 (EST) |
branch: master
commit f2019fc676c2206bbdc53855e3bc4f1086676d3d
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Fix case-insensitive completion of buffer names
* test/src/minibuf-tests.el (test-try-completion-ignore-case):
New test, suggested by Stefan Monnier <address@hidden>.
* src/minibuf.c (Ftry_completion): Don't treat strings that
are identical but for the case as if they were identical for
the purposes of not counting the same string twice. This
fixes case-insensitive completion when all the candidates are
identical but for the letter-case. (Bug#11339)
---
src/minibuf.c | 15 ++++++++++-----
test/src/minibuf-tests.el | 11 +++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/minibuf.c b/src/minibuf.c
index f6cf47f..1e87c50 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1323,13 +1323,13 @@ is used to further constrain the set of candidates. */)
else
{
compare = min (bestmatchsize, SCHARS (eltstring));
- tem = Fcompare_strings (bestmatch, zero,
- make_fixnum (compare),
- eltstring, zero,
- make_fixnum (compare),
+ Lisp_Object lcompare = make_fixnum (compare);
+ tem = Fcompare_strings (bestmatch, zero, lcompare,
+ eltstring, zero, lcompare,
completion_ignore_case ? Qt : Qnil);
matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1;
+ Lisp_Object old_bestmatch = bestmatch;
if (completion_ignore_case)
{
/* If this is an exact match except for case,
@@ -1363,7 +1363,12 @@ is used to further constrain the set of candidates. */)
bestmatch = eltstring;
}
if (bestmatchsize != SCHARS (eltstring)
- || bestmatchsize != matchsize)
+ || bestmatchsize != matchsize
+ || (completion_ignore_case
+ && !EQ (Fcompare_strings (old_bestmatch, zero, lcompare,
+ eltstring, zero, lcompare,
+ Qnil),
+ Qt)))
/* Don't count the same string multiple times. */
matchcount += matchcount <= 1;
bestmatchsize = matchsize;
diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el
index 12b018b..c648928 100644
--- a/test/src/minibuf-tests.el
+++ b/test/src/minibuf-tests.el
@@ -399,5 +399,16 @@
(minibuf-tests--test-completion-regexp
#'minibuf-tests--strings-to-symbol-hashtable))
+(ert-deftest test-try-completion-ignore-case ()
+ (let ((completion-ignore-case t))
+ (should (equal (try-completion "bar" '("bAr" "barfoo")) "bAr"))
+ (should (equal (try-completion "bar" '("bArfoo" "barbaz")) "bar"))
+ (should (equal (try-completion "bar" '("bArfoo" "barbaz"))
+ (try-completion "bar" '("barbaz" "bArfoo"))))
+ ;; bug#11339
+ (should (equal (try-completion "baz" '("baz" "bAz")) "baz")) ;And not `t'!
+ (should (equal (try-completion "baz" '("bAz" "baz"))
+ (try-completion "baz" '("baz" "bAz"))))))
+
;;; minibuf-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f2019fc: Fix case-insensitive completion of buffer names,
Eli Zaretskii <=