[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d22a3e5afe7 2/2: * lisp/simple.el (next-line-completion): Better
From: |
Juri Linkov |
Subject: |
master d22a3e5afe7 2/2: * lisp/simple.el (next-line-completion): Better handing of group lines. |
Date: |
Thu, 25 Jan 2024 12:55:42 -0500 (EST) |
branch: master
commit d22a3e5afe75c9f4a18926cce16c1a13fa912df2
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/simple.el (next-line-completion): Better handing of group lines.
Simplify to not compare the result of 'move-to-column'
with the value 'column'. Such comparison prevented from moving
over lines without completion candidates such as group lines (bug#68688).
* test/lisp/minibuffer-tests.el (completions-group-navigation-test):
Add more group candidates to create more columns and to test
moving over group lines and over columns without candidates.
---
lisp/simple.el | 4 +--
test/lisp/minibuffer-tests.el | 64 +++++++++++++++++++++++++++++++------------
2 files changed, 48 insertions(+), 20 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 1157bd578fd..8246b9cab81 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10062,7 +10062,7 @@ Also see the `completion-auto-wrap' variable."
(while (and (not found)
(eq (forward-line 1) 0)
(not (eobp))
- (eq (move-to-column column) column))
+ (move-to-column column))
(when (get-text-property (point) 'mouse-face)
(setq found t)))
(when (not found)
@@ -10086,7 +10086,7 @@ Also see the `completion-auto-wrap' variable."
(completion--move-to-candidate-start)
(while (and (not found)
(eq (forward-line -1) 0)
- (eq (move-to-column column) column))
+ (move-to-column column))
(when (get-text-property (point) 'mouse-face)
(setq found t)))
(when (not found)
diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el
index d104858b0d0..07c4dbc3197 100644
--- a/test/lisp/minibuffer-tests.el
+++ b/test/lisp/minibuffer-tests.el
@@ -565,35 +565,63 @@
(if transform
name
(pcase name
- (`"aa" "Group 1")
- (`"ab" "Group 2")
- (`"ac" "Group 3")))))
+ (`"aa1" "Group 1")
+ (`"aa2" "Group 1")
+ (`"aa3" "Group 1")
+ (`"aa4" "Group 1")
+ (`"ab1" "Group 2")
+ (`"ac1" "Group 3")
+ (`"ac2" "Group 3")))))
(category . unicode-name))
- (complete-with-action action '("aa" "ab" "ac") string pred)))
+ (complete-with-action action '("aa1" "aa2" "aa3" "aa4" "ab1" "ac1"
"ac2")
+ string pred)))
(insert "a")
(minibuffer-completion-help)
(switch-to-completions)
- (should (equal "aa" (get-text-property (point) 'completion--string)))
+ (should (equal "aa1" (get-text-property (point) 'completion--string)))
(let ((completion-auto-wrap t))
- (next-completion 3))
- (should (equal "aa" (get-text-property (point) 'completion--string)))
+ (next-completion 7))
+ (should (equal "aa1" (get-text-property (point) 'completion--string)))
(let ((completion-auto-wrap nil))
- (next-completion 3))
- (should (equal "ac" (get-text-property (point) 'completion--string)))
+ (next-completion 7))
+ (should (equal "ac2" (get-text-property (point) 'completion--string)))
- (first-completion)
(let ((completion-auto-wrap t))
+ ;; First column
+ (first-completion)
(next-line-completion 1)
- (should (equal "ab" (get-text-property (point) 'completion--string)))
- (next-line-completion 2)
- (should (equal "aa" (get-text-property (point) 'completion--string)))
+ (should (equal "aa4" (get-text-property (point) 'completion--string)))
+ (next-line-completion 3)
+ (should (equal "aa1" (get-text-property (point) 'completion--string)))
(previous-line-completion 2)
- (should (equal "ab" (get-text-property (point) 'completion--string))))
+ (should (equal "ab1" (get-text-property (point) 'completion--string)))
+
+ ;; Second column
+ (first-completion)
+ (next-completion 1)
+ (should (equal "aa2" (get-text-property (point) 'completion--string)))
+ (next-line-completion 1)
+ (should (equal "ac2" (get-text-property (point) 'completion--string)))
+ (next-line-completion 1)
+ (should (equal "aa2" (get-text-property (point) 'completion--string)))
+ (previous-line-completion 1)
+ (should (equal "ac2" (get-text-property (point) 'completion--string)))
+ (previous-line-completion 1)
+ (should (equal "aa2" (get-text-property (point) 'completion--string)))
+
+ ;; Third column
+ (first-completion)
+ (next-completion 2)
+ (should (equal "aa3" (get-text-property (point) 'completion--string)))
+ (next-line-completion 1)
+ (should (equal "aa3" (get-text-property (point) 'completion--string))))
+
(let ((completion-auto-wrap nil))
- (next-line-completion 3)
- (should (equal "ac" (get-text-property (point) 'completion--string)))
- (previous-line-completion 3)
- (should (equal "aa" (get-text-property (point) 'completion--string))))))
+ (first-completion)
+ (next-line-completion 7)
+ (should (equal "ac2" (get-text-property (point) 'completion--string)))
+ (previous-line-completion 7)
+ (should (equal "aa1" (get-text-property (point) 'completion--string))))))
(provide 'minibuffer-tests)
;;; minibuffer-tests.el ends here