Skip to content

Commit

Permalink
ivy.el (ivy-partial): Return nil when comletion was not updated
Browse files Browse the repository at this point in the history
* ivy-test.el (counsel-find-file-with-spaces): Add tests.

Fixes abo-abo#2103
  • Loading branch information
abo-abo authored and astoff committed Jan 1, 2021
1 parent ff0bfa9 commit 3e93a39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ivy-test.el
Expand Up @@ -1162,7 +1162,7 @@ a buffer visiting a file."
(shell-command
"git clone -b test --single-branch https://github.com/abo-abo/swiper/ tests"))
(let ((default-directory (expand-file-name "tests/"))
(version "b1a2bbf"))
(version "935fde0"))
(shell-command
(format "git checkout %s || git fetch && git checkout %s" version version))))

Expand Down Expand Up @@ -1192,6 +1192,25 @@ a buffer visiting a file."
:dir "tests/find-file/dotfiles/"))
"tests/find-file/dotfiles/.foobar1")))

(ert-deftest counsel-find-file-with-spaces ()
(counsel--setup-test-files)
(let ((ivy-extra-directories nil))
(should (string=
(file-relative-name
(ivy-with '(counsel-find-file) "TAB TAB TAB TAB"
:dir "tests/find-file/directories-with-spaces/"))
"tests/find-file/directories-with-spaces/bar baz i/file1"))
(should (string=
(file-relative-name
(ivy-with '(counsel-find-file) "C-n TAB TAB TAB TAB"
:dir "tests/find-file/directories-with-spaces/"))
"tests/find-file/directories-with-spaces/bar baz ii/file2"))
(should (string=
(file-relative-name
(ivy-with '(counsel-find-file) "TAB C-n TAB TAB TAB TAB"
:dir "tests/find-file/directories-with-spaces/"))
"tests/find-file/directories-with-spaces/bar baz ii/file2"))))

(provide 'ivy-test)

;;; ivy-test.el ends here
1 change: 1 addition & 0 deletions ivy.el
Expand Up @@ -1041,6 +1041,7 @@ If the text hasn't changed as a result, forward to `ivy-alt-done'."
ivy--old-cands)))))
(cond ((eq new t) nil)
((string= new ivy-text) nil)
((string= (car tail) new) nil)
(new
(delete-region (minibuffer-prompt-end) (point-max))
(setcar tail
Expand Down

0 comments on commit 3e93a39

Please sign in to comment.