Skip to content

Commit

Permalink
ivy-test.el (counsel-find-file-single-match-directories): Add test
Browse files Browse the repository at this point in the history
Fixes #2596
  • Loading branch information
abo-abo committed Jun 5, 2020
1 parent 544e7de commit 3e281d0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions ivy-test.el
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ivy.el
Expand Up @@ -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)))
Expand Down
Empty file.
Empty file.

0 comments on commit 3e281d0

Please sign in to comment.