From 8903da305bccaabe6e8fb2665b0d1c6f8861e024 Mon Sep 17 00:00:00 2001 From: Vebjorn Ljosa <155655614+vljosa-vivodyne@users.noreply.github.com> Date: Tue, 19 Mar 2024 06:43:03 -0400 Subject: [PATCH] Fix client settings cannot be overridden (#4383) Create hash table with `:test 'equal` so that `lsp-register-custom-settings` can be called again to override settings. Resolves #4382 --- lsp-mode.el | 2 +- test/lsp-mode-test.el | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lsp-mode.el b/lsp-mode.el index dc1d001ec84..649259da390 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -8514,7 +8514,7 @@ session workspace folder configuration for the server." (funcall initialization-options-or-fn) initialization-options-or-fn))) -(defvar lsp-client-settings (make-hash-table) +(defvar lsp-client-settings (make-hash-table :test 'equal) "For internal use, any external users please use `lsp-register-custom-settings' function instead") diff --git a/test/lsp-mode-test.el b/test/lsp-mode-test.el index 3d355d466b1..c1c7989d336 100644 --- a/test/lsp-mode-test.el +++ b/test/lsp-mode-test.el @@ -175,4 +175,13 @@ "textDocument/hover"))) 2))) +(ert-deftest lsp-test--register-custom-settings-override () + "Test that custom settings can be overridden." + (clrhash lsp-client-settings) + (lsp-register-custom-settings '(("foo" "original value"))) + (lsp-register-custom-settings '(("foo" "new value"))) + (should (equal (gethash "foo" lsp-client-settings) '("new value")))) + + + ;;; lsp-mode-test.el ends here