Skip to content

Commit c78329f

Browse files
committed
Test display of code lens
1 parent 2ef41df commit c78329f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

test/lsp-mock-server-test.el

+19
Original file line numberDiff line numberDiff line change
@@ -840,4 +840,23 @@ line 3 words here and here
840840
(should (equal (line-number-at-pos) (1+ hint-line)))
841841
(should (equal (current-column) hint-col))))))))
842842

843+
(ert-deftest lsp-test-server-provides-code-lens ()
844+
"lsp-mode accepts code lenses from the server and displays them."
845+
(let ((line 2))
846+
(lsp-test-schedule-response
847+
"textDocument/codeLens"
848+
(vconcat (list `(:range (:start (:line ,line :character 0)
849+
:end (:line ,line :character 1))
850+
:command (:title "My command"
851+
:command "myCommand")))))
852+
(lsp-mock-run-with-mock-server
853+
(lsp-test-sync-wait (lsp-test-all-overlays 'lsp-lens))
854+
(let ((lenses (lsp-test-all-overlays 'lsp-lens)))
855+
(should (eq (length lenses) 1))
856+
(message "%s" (overlay-properties (car lenses)))
857+
(should (string-match-p "My command"
858+
(overlay-get (car lenses) 'after-string)))
859+
(goto-char (overlay-start (car lenses)))
860+
(should (equal (line-number-at-pos) (- line 1)))))))
861+
843862
;;; lsp-mock-server-test.el ends here

test/mock-lsp-server.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
:codeActionProvider t
8585
:declarationProvider t
8686
:definitionProvider t
87-
:inlayHintProvider t)
87+
:inlayHintProvider t
88+
:codeLensProvider (:resolveProvider ()))
8889
"Capabilities of the server.")
8990

9091
(defun greeting (id)

0 commit comments

Comments
 (0)