Skip to content

Commit 6aedd69

Browse files
committed
Delete duplicates when extracting candidates. fixes #26
1 parent 2c0b8d6 commit 6aedd69

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bash-completion.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ result. See `bash-completion-fix' for more details."
759759
(push (bash-completion-fix
760760
completion parsed-stub unparsed-stub open-quote completion-type nil)
761761
result))
762-
(nreverse result))))
762+
(delete-dups (nreverse result)))))
763763

764764
(defun bash-completion-fix
765765
(str parsed-prefix unparsed-prefix open-quote completion-type single)

test/bash-completion-test.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,15 @@ Return (const return-value new-buffer-content)"
582582
"hello world\nhello \n\n"
583583
(cl-letf (((symbol-function 'bash-completion-buffer)
584584
(lambda () (current-buffer))))
585-
(bash-completion-extract-candidates "hello" "hello" nil nil)))))))
585+
(bash-completion-extract-candidates "hello" "hello" nil nil)))))
586+
(should
587+
(equal
588+
'("hello" "hellish" "hellow")
589+
(bash-completion-test-with-buffer
590+
"hello\nhellish\nhello\nhellow\n"
591+
(cl-letf (((symbol-function 'bash-completion-buffer)
592+
(lambda () (current-buffer))))
593+
(bash-completion-extract-candidates "hell" "hell" nil nil)))))))
586594

587595
(ert-deftest bash-completion-nonsep-test ()
588596
(should (equal "^ \t\n\r;&|'\"#"

0 commit comments

Comments
 (0)