From 8ed931570f3f9c0ec15ffbaa280add9118334b8d Mon Sep 17 00:00:00 2001 From: Yikai Zhao Date: Sun, 17 Dec 2023 21:07:49 +0800 Subject: [PATCH 1/2] yield thread while waiting for native json rpc sit-for may not yield if there's input pending --- lsp-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lsp-mode.el b/lsp-mode.el index b13a7467b7d..5b6dbe9d832 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -3296,7 +3296,9 @@ If NO-WAIT is non-nil send the request as notification." :cancel-token :sync-request) (while (not (or resp-error resp-result)) (if (functionp 'json-rpc-connection) - (catch 'lsp-done (sit-for 0.01)) + (catch 'lsp-done + (thread-yield) + (sit-for 0.01)) (catch 'lsp-done (accept-process-output nil From 3dad4134caf70ea533418ccd7ca9a50ce531f38f Mon Sep 17 00:00:00 2001 From: Yikai Zhao Date: Thu, 21 Dec 2023 09:37:29 +0800 Subject: [PATCH 2/2] use sleep-for instead of thread-yield + sit-for --- lsp-mode.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lsp-mode.el b/lsp-mode.el index 5b6dbe9d832..10b1f75a843 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -3296,9 +3296,7 @@ If NO-WAIT is non-nil send the request as notification." :cancel-token :sync-request) (while (not (or resp-error resp-result)) (if (functionp 'json-rpc-connection) - (catch 'lsp-done - (thread-yield) - (sit-for 0.01)) + (catch 'lsp-done (sleep-for 0.01)) (catch 'lsp-done (accept-process-output nil