1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

; Eglot: unbreak "lsp-abiding-column" test for newer clangd

Newer/newest clangd support more encodings and actually
negotiate with us, so test shouldn't assume UTF-16..

* test/lisp/progmodes/eglot-tests.el
(eglot-tests--lsp-abiding-column-1): Tweak.
This commit is contained in:
João Távora 2025-11-10 12:28:14 +00:00
parent 683e7462df
commit 1772a4e468

View file

@ -1005,26 +1005,31 @@ int main() {
(eglot--with-fixture (eglot--with-fixture
'(("project" . '(("project" .
(("foo.c" . "const char write_data[] = u8\"🚂🚃🚄🚅🚆🚈🚇🚈🚉🚊🚋🚌🚎🚝🚞🚟🚠🚡🛤🛲\";")))) (("foo.c" . "const char write_data[] = u8\"🚂🚃🚄🚅🚆🚈🚇🚈🚉🚊🚋🚌🚎🚝🚞🚟🚠🚡🛤🛲\";"))))
(let ((eglot-server-programs (let (expected-column
(eglot-server-programs
'((c-mode . ("clangd"))))) '((c-mode . ("clangd")))))
(with-current-buffer (with-current-buffer
(eglot--find-file-noselect "project/foo.c") (eglot--find-file-noselect "project/foo.c")
(setq-local eglot-move-to-linepos-function #'eglot-move-to-utf-16-linepos)
(setq-local eglot-current-linepos-function #'eglot-utf-16-linepos)
(eglot--sniffing (:client-notifications c-notifs) (eglot--sniffing (:client-notifications c-notifs)
(eglot--tests-connect) (eglot--tests-connect)
(end-of-line) (end-of-line)
;; will be 71 if utf-16 was negotiated, 51 if utf-32,
;; something else if utf-8
(setq expected-column (funcall eglot-current-linepos-function))
(eglot--test-message
"Looks like we negotiated %S as the offset encoding"
(list eglot-move-to-linepos-function eglot-current-linepos-function))
(insert "p ") (insert "p ")
(eglot--signal-textDocument/didChange) (eglot--signal-textDocument/didChange)
(eglot--wait-for (c-notifs 2) (&key params &allow-other-keys) (eglot--wait-for (c-notifs 2) (&key params &allow-other-keys)
(message "PARAMS=%S" params) (should (equal expected-column
(should (equal 71 (eglot-tests--get (eglot-tests--get
params params
'(:contentChanges 0 '(:contentChanges 0
:range :start :character))))) :range :start :character)))))
(beginning-of-line) (beginning-of-line)
(should (eq eglot-move-to-linepos-function #'eglot-move-to-utf-16-linepos)) (funcall eglot-move-to-linepos-function expected-column)
(funcall eglot-move-to-linepos-function 71)
(should (looking-at "p"))))))) (should (looking-at "p")))))))
(ert-deftest eglot-test-lsp-abiding-column () (ert-deftest eglot-test-lsp-abiding-column ()