Skip to content

Commit 62ad341

Browse files
committed
Optmize resheduling idle hook
Fixes #2224 Avoid redundant calls to reshedule
1 parent 65034e1 commit 62ad341

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lsp-diagnostics.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ from the language server."
179179
(->> lsp--cur-workspace
180180
(lsp--workspace-buffers)
181181
(mapc (lambda (buffer)
182-
(when (lsp-buffer-live-p buffer)
182+
(when (and (lsp-buffer-live-p buffer)
183+
(or
184+
(not (bufferp buffer))
185+
(and (get-buffer-window buffer)
186+
(not (-contains? (buffer-local-value 'lsp-on-idle-hook buffer)
187+
'lsp-diagnostics--flycheck-buffer)))))
183188
(lsp-with-current-buffer buffer
184189
(add-hook 'lsp-on-idle-hook #'lsp-diagnostics--flycheck-buffer nil t)
185190
(lsp--idle-reschedule (current-buffer)))))))))

lsp-mode.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,8 +1974,7 @@ WORKSPACE is the workspace that contains the diagnostics."
19741974
(remhash file workspace-diagnostics)
19751975
(puthash file (append diagnostics nil) workspace-diagnostics))
19761976

1977-
(run-hooks 'lsp-diagnostics-updated-hook)
1978-
(lsp--idle-reschedule (current-buffer))))
1977+
(run-hooks 'lsp-diagnostics-updated-hook)))
19791978

19801979

19811980

0 commit comments

Comments
 (0)