Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix #4501: Auto adjust stale diagnostic ranges on document changes#4513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
necto wants to merge18 commits intoemacs-lsp:master
base:master
Choose a base branch
Loading
fromnecto:az/fix-transient-ranges
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
5f3e192
Check for overlay leaks
nectoJul 24, 2024
716076e
Add a e2e test for flycheck
nectoJul 25, 2024
7a659a6
Embed timeout into lsp-test-sync-wait
nectoJul 25, 2024
c6f3cbb
Demonstrate flycheck getting diag ranges off
nectoJul 25, 2024
2b6210d
Test delayed diagnostic update with flymake
nectoJul 26, 2024
11d5282
[NFC] Make SAMPLE-FILE parameter explicit in run-with-mock-server
nectoJul 27, 2024
5fb1620
Test diagnostic update behavior inside org code blocks
nectoJul 27, 2024
b59a9f0
Add diagnostic-overlay-map to lsp--workspace
nectoJul 27, 2024
208e7e3
Rely on overlays to automaticall adjust diagnostic ranges
nectoJul 27, 2024
ebd912f
Add changelog record
nectoJul 28, 2024
64e7464
[NFC] simplify puthash invocation
nectoJul 28, 2024
a49540e
[NFC] remove superfluous progn
nectoJul 28, 2024
10cd1d7
[NFC] tips in the doc for diagnostic-overlay-map
nectoJul 28, 2024
9c57234
Restore the perf short-cut for single-workspace case
nectoJul 28, 2024
a6faefa
Fix lsp-diagnostics broken by previous commit
nectoJul 28, 2024
e68ea29
Missing test fixture
nectoJul 28, 2024
00954dc
Tag the test for experimental org-mode feature
nectoJul 28, 2024
38d7b78
Merge branch 'master' into az/fix-transient-ranges
nectoAug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Check for overlay leaks
  • Loading branch information
@necto
necto committedJul 28, 2024
commit5f3e192b45b2a65646ba51e3c18f3f2f368e673b
64 changes: 42 additions & 22 deletionstest/lsp-mock-server-test.el
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -199,6 +199,11 @@ Returns the non-nil return value of CONDITION-FUNC."
"Wait for the CONDITION to become non-nil and return it."
`(lsp-test--sync-wait-for (lambda () ,condition)))

(defun lsp-test-relevant-overlays ()
"Collect all overlays that might have been produced by LSP."
(seq-filter (lambda (ovl) (null (overlay-get ovl 'pulse-delete)))
(overlays-in (point-min) (point-max))))

(defun lsp-mock--run-with-mock-server (test-body)
"Run TEST-BODY function with mock LSP client connected to the mock server.

Expand All@@ -210,36 +215,43 @@ opens the `lsp-test-sample-file' and starts the mock server."
(lsp-enable-snippet nil) ; Avoid warning that lsp-yasnippet is not intalled
(lsp-warn-no-matched-clients nil) ; Mute warning LSP can't figure out src lang
(workspace-root (file-name-directory lsp-test-sample-file))
(initial-server-count (lsp-test-total-folder-count)))
(initial-server-count (lsp-test-total-folder-count))
(initial-overlay-count nil))
(register-mock-client) ; register mock client as the one an only lsp client

;; xref in emacs 27.2 does not have these vars,
;; but lsp-mode uses them in lsp-show-xrefs.
;; For the purpose of this test, it does not matter.
(unless (boundp 'xref-auto-jump-to-first-xref)
(defvar xref-auto-jump-to-first-xref nil))
(unless (boundp 'xref-auto-jump-to-first-definition)
(defvar xref-auto-jump-to-first-definition nil))
;; xref in emacs 27.2 does not have these vars,
;; but lsp-mode uses them in lsp-show-xrefs.
;; For the purpose of this test, it does not matter.
(unless (boundp 'xref-auto-jump-to-first-xref)
(defvar xref-auto-jump-to-first-xref nil))
(unless (boundp 'xref-auto-jump-to-first-definition)
(defvar xref-auto-jump-to-first-definition nil))

(lsp-workspace-folders-add workspace-root)
(let* ((buf (find-file-noselect lsp-test-sample-file)))
(unwind-protect
(with-timeout (5 (error "Timeout running a test with mock server"))
(with-current-buffer buf
(prog-mode)
(lsp)
;; Make sure the server started
(should (eq (lsp-test-total-folder-count) (1+ initial-server-count)))
(lsp-test-sync-wait (eq 'initialized
(lsp--workspace-status (cl-first (lsp-workspaces)))))
(funcall test-body)))
(progn
(with-timeout (5 (error "Timeout running a test with mock server"))
(with-current-buffer buf
(prog-mode)
(setq initial-overlay-count (length (lsp-test-relevant-overlays)))
(lsp)
;; Make sure the server started
(should (eq (lsp-test-total-folder-count) (1+ initial-server-count)))
(lsp-test-sync-wait (eq 'initialized
(lsp--workspace-status (cl-first (lsp-workspaces)))))
(funcall test-body)))
(with-timeout (1 (error "Timeout waiting for overlays to dissolve"))
(with-current-buffer buf
(lsp-test-sync-wait (equal initial-overlay-count (length (lsp-test-relevant-overlays)))))))
(with-current-buffer buf
(should (equal initial-overlay-count (length (lsp-test-relevant-overlays))))
(set-buffer-modified-p nil); Inhibut the "kill unsaved buffer"p prompt
(kill-buffer buf))
(lsp-workspace-folders-remove workspace-root)
;; Remove possibly unhandled commands
(when (file-exists-p lsp-test-mock-server-command-file)
(delete-file lsp-test-mock-server-command-file))))
(delete-file lsp-test-mock-server-command-file))))
(with-timeout (5 (error "LSP mock server refuses to stop"))
;; Make sure the server stopped
(lsp-test-sync-wait (= initial-server-count (lsp-test-total-folder-count))))))
Expand DownExpand Up@@ -557,6 +569,7 @@ TEST-FN is a function to call with the temporary window."
(lsp-test-sync-wait (progn (should (lsp-workspaces))
(lsp-test-all-overlays-as-ranges
'lsp-highlight)))

(let ((highlights (lsp-test-all-overlays-as-ranges 'lsp-highlight)))
(should (eq (length highlights) 3))
(should (equal (nth 0 highlights)
Expand All@@ -570,7 +583,10 @@ TEST-FN is a function to call with the temporary window."
(should (equal (nth 2 highlights)
(lsp-test-range-make (buffer-string)
"line 3 words here and here"
" ^^^^"))))))))
" ^^^^"))))
;; Remove highlights
(lsp-test-schedule-response "textDocument/documentHighlight" [])
(lsp-document-highlight)))))

(defun lsp-test-index-to-pos (idx)
"Convert 0-based integer IDX to a position in the corrent buffer.
Expand DownExpand Up@@ -843,7 +859,10 @@ line 3 words here and here
(goto-char (overlay-start (car hints)))
; 1+ to convert 0-based LSP line number to 1-based Emacs line number
(should (equal (line-number-at-pos) (1+ hint-line)))
(should (equal (current-column) hint-col))))))))
(should (equal (current-column) hint-col)))
;; Disable inlay hints to remove overlays
(lsp-test-schedule-response "textDocument/inlayHint" [])
(run-hooks 'lsp-on-idle-hook))))))

(ert-deftest lsp-mock-server-provides-code-lens ()
"lsp-mode accepts code lenses from the server and displays them."
Expand All@@ -858,10 +877,11 @@ line 3 words here and here
(lsp-test-sync-wait (lsp-test-all-overlays 'lsp-lens))
(let ((lenses (lsp-test-all-overlays 'lsp-lens)))
(should (eq (length lenses) 1))
(message "%s" (overlay-properties (car lenses)))
(should (string-match-p "My command"
(overlay-get (car lenses) 'after-string)))
(goto-char (overlay-start (car lenses)))
(should (equal (line-number-at-pos) (- line 1)))))))
(should (equal (line-number-at-pos) (- line 1))))
;; Remove lens overlays
(lsp-lens-hide))))

;;; lsp-mock-server-test.el ends here
4 changes: 1 addition & 3 deletionstest/mock-lsp-server.el
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,9 +142,7 @@ Key is the method, and value is the `result' field in the response.")
This function is useful for external commands,
allowing control over the server responses.

You can schedule only one response for a method for the entire session."
(when (gethash method scheduled-responses)
(error "Response for method %s is already scheduled" method))
You can schedule only one response for a method at a time."
(puthash method result scheduled-responses))

(defun get-method (input)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp