diff --git a/CHANGELOG.org b/CHANGELOG.org index 29e859c92e..aa75377d85 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -8,6 +8,7 @@ * Added a new optional ~:action-filter~ argument when defining LSP clients that allows code action requests to be modified before they are sent to the server. This is used by the Haskell language server client to work around an ~lsp-mode~ parsing quirk that incorrectly sends ~null~ values instead of ~false~ in code action requests. * Add support for C# via the [[https://github.com/dotnet/roslyn/tree/main/src/LanguageServer][Roslyn language server]]. * Add basic support for [[https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics][pull diagnostics]] requests. + * Add ~lsp-flush-delayed-changes-before-next-message~ customization point to enforce throttling document change notifications. ** 9.0.0 * Add language server config for QML (Qt Modeling Language) using qmlls. diff --git a/lsp-mode.el b/lsp-mode.el index 05cac9b3c2..2c4b1827e8 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -6743,13 +6743,24 @@ textDocument/didOpen for the new file." (advice-add 'set-visited-file-name :around #'lsp--on-set-visited-file-name) -(defvar lsp--flushing-delayed-changes nil) +(defcustom lsp-flush-delayed-changes-before-next-message t + "If non-nil send the document changes update before sending other messages. + +If nil, and `lsp-debounce-full-sync-notifications' is non-nil, + change notifications will be throttled by + `lsp-debounce-full-sync-notifications-interval' regardless of + other messages." + :group 'lsp-mode + :type 'boolean) + +(defvar lsp--not-flushing-delayed-changes t) (defun lsp--send-no-wait (message proc) "Send MESSAGE to PROC without waiting for further output." - (unless lsp--flushing-delayed-changes - (let ((lsp--flushing-delayed-changes t)) + (when (and lsp--not-flushing-delayed-changes + lsp-flush-delayed-changes-before-next-message) + (let ((lsp--not-flushing-delayed-changes nil)) (lsp--flush-delayed-changes))) (lsp-process-send proc message))