aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov2024-08-25 18:23:51 +0300
committerDmitry Gutov2024-08-25 18:23:51 +0300
commit713069dd7a87cff8388c25f1bc2c2c1b5217b1ca (patch)
tree24834f22583d6c7c7b8c3b4fcb42cc99cdc6175c /test
parent096730510cdf8c582972f68afeef3226ee5810ca (diff)
downloademacs-713069dd7a87cff8388c25f1bc2c2c1b5217b1ca.tar.gz
emacs-713069dd7a87cff8388c25f1bc2c2c1b5217b1ca.zip
[Eglot] Stricter "expand common" behavior
* lisp/progmodes/eglot.el (eglot--dumb-tryc): Check that the expanded string matches every completion strictly (bug#72705). And in the fallback case, check whether the table matches the original prefix at all. Return nil otherwise. * test/lisp/progmodes/eglot-tests.el (eglot-test-stop-completion-on-nonprefix) (eglot-test-try-completion-nomatch): Corresponding tests. * etc/EGLOT-NEWS: New entry.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/eglot-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el
index 3b67045122f..e0168baee54 100644
--- a/test/lisp/progmodes/eglot-tests.el
+++ b/test/lisp/progmodes/eglot-tests.el
@@ -645,6 +645,36 @@ directory hierarchy."
645 (forward-line -1) 645 (forward-line -1)
646 (should (looking-at "Complete, but not unique"))))))) 646 (should (looking-at "Complete, but not unique")))))))
647 647
648(ert-deftest eglot-test-stop-completion-on-nonprefix ()
649 "Test completion also resulting in 'Complete, but not unique'."
650 (skip-unless (executable-find "clangd"))
651 (eglot--with-fixture
652 `(("project" . (("coiso.c" .
653 ,(concat "int foot; int footer; int fo_obar;"
654 "int main() {foo")))))
655 (with-current-buffer
656 (eglot--find-file-noselect "project/coiso.c")
657 (eglot--wait-for-clangd)
658 (goto-char (point-max))
659 (completion-at-point)
660 (should (looking-back "foo")))))
661
662(ert-deftest eglot-test-try-completion-nomatch ()
663 "Test completion table with non-matching input, returning nil."
664 (skip-unless (executable-find "clangd"))
665 (eglot--with-fixture
666 `(("project" . (("coiso.c" .
667 ,(concat "int main() {abc")))))
668 (with-current-buffer
669 (eglot--find-file-noselect "project/coiso.c")
670 (eglot--wait-for-clangd)
671 (goto-char (point-max))
672 (should
673 (null
674 (completion-try-completion
675 "abc"
676 (nth 2 (eglot-completion-at-point)) nil 3))))))
677
648(ert-deftest eglot-test-try-completion-inside-symbol () 678(ert-deftest eglot-test-try-completion-inside-symbol ()
649 "Test completion table inside symbol, with only prefix matching." 679 "Test completion table inside symbol, with only prefix matching."
650 (skip-unless (executable-find "clangd")) 680 (skip-unless (executable-find "clangd"))