emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ivy-hydra 3e281d0 315/395: ivy-test.el (counsel-find-fi


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 3e281d0 315/395: ivy-test.el (counsel-find-file-single-match-directories): Add test
Date: Thu, 25 Feb 2021 08:32:28 -0500 (EST)

branch: externals/ivy-hydra
commit 3e281d03b7cf4131b642f001baeabe55a5ce9768
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    ivy-test.el (counsel-find-file-single-match-directories): Add test
    
    Fixes #2596
---
 ivy-test.el                                              | 16 ++++++++++++++--
 ivy.el                                                   |  4 +++-
 tests/find-file/single-match-directories/a/file_in_a.txt |  0
 .../find-file/single-match-directories/ba/file_in_ba.txt |  0
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ivy-test.el b/ivy-test.el
index 43f2551..ac1d250 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1526,10 +1526,22 @@ a buffer visiting a file."
                         :dir "tests/find-file/directories-with-spaces/"))
              "tests/find-file/directories-with-spaces/bar baz ii/file2"))))
 
+(ert-deftest counsel-find-file-single-match-directories ()
+  (should (string= (let ((ivy-extra-directories nil))
+                     (file-relative-name
+                      (ivy-with '(counsel-find-file) "a TAB TAB TAB"
+                                :dir 
"tests/find-file/single-match-directories/")))
+                   "tests/find-file/single-match-directories/a/file_in_a.txt"))
+  (should (string= (let ((ivy-extra-directories nil))
+                     (file-relative-name
+                      (ivy-with '(counsel-find-file) "b TAB TAB TAB"
+                                :dir 
"tests/find-file/single-match-directories/")))
+                   
"tests/find-file/single-match-directories/ba/file_in_ba.txt")))
+
 (ert-deftest counsel--split-string-with-eol-cr ()
   (should
-     (equal (counsel--split-string "one\rtwo")
-            '("one" "two"))))
+   (equal (counsel--split-string "one\rtwo")
+          '("one" "two"))))
 
 (ert-deftest counsel--split-string-with-eol-lf ()
   (should
diff --git a/ivy.el b/ivy.el
index 8177fda..82118b8 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1095,7 +1095,9 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
   (when (and
          (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
          (= 1 (length
-               (ivy--re-filter ivy-regex ivy--all-candidates)))
+               (ivy--re-filter
+                (concat "^" (string-remove-prefix "^" ivy-regex))
+                ivy--all-candidates)))
          (let ((default-directory ivy--directory))
            (file-directory-p (ivy-state-current ivy-last))))
     (ivy--directory-done)))
diff --git a/tests/find-file/single-match-directories/a/file_in_a.txt 
b/tests/find-file/single-match-directories/a/file_in_a.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/find-file/single-match-directories/ba/file_in_ba.txt 
b/tests/find-file/single-match-directories/ba/file_in_ba.txt
new file mode 100644
index 0000000..e69de29



reply via email to

[Prev in Thread] Current Thread [Next in Thread]