Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #559 #561

Merged
merged 2 commits into from
Mar 11, 2021
Merged

fix #559 #561

merged 2 commits into from
Mar 11, 2021

Conversation

tatchi
Copy link
Collaborator

@tatchi tatchi commented Mar 11, 2021

The problem was that Params was an array of array of string, while the lsp server was expecting an array of string.

I fixed it on the extension side, but if we want to keep sending an array of array of string, we can instead adapt the lsp as following:

diff --git a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml b/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml
index 15733db..84c24b9 100644
--- a/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml
+++ b/ocaml-lsp-server/src/custom_requests/req_switch_impl_intf.ml
@@ -14,7 +14,8 @@ let switch (param : DocumentUri.t) : (Json.t, Jsonrpc.Response.Error.t) result =
 let on_request ~(params : Jsonrpc.Message.Structured.t option) _ =
   Fiber.return
     ( match params with
-    | Some (`List [ `String (file_uri : DocumentUri.t) ]) -> switch file_uri
+    | Some (`List [ `List [ `String (file_uri : DocumentUri.t) ] ]) ->
+      switch file_uri
     | Some json ->
       Error
         (Jsonrpc.Response.Error.make ~code:InvalidRequest

@mnxn
Copy link
Collaborator

mnxn commented Mar 11, 2021

Thanks!

I can confirm this fixes it for ocaml-lsp 1.4.0. Handling a nested list in the language server doesn't look right, so I think fixing it on the extension side is the correct decision.

I believe this happened because after vscode-languageclient 7.0.0, LanguageClient.sendRequest automatically wrapped the parameter in a list, so adding the Jsonoo.Encode.list was unnecessary.

@tmattio
Copy link
Collaborator

tmattio commented Mar 11, 2021

I believe this happened because after vscode-languageclient 7.0.0

Correct, I had to fix the unit tests on the LSP side because of that too: https://github.com/ocaml/ocaml-lsp/pull/385/files

Copy link
Collaborator

@tmattio tmattio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tatchi Could you add an entry in the Changelog for this?

@tmattio tmattio merged commit 41ff847 into ocamllabs:master Mar 11, 2021
@tmattio
Copy link
Collaborator

tmattio commented Mar 11, 2021

Thanks 🎉

@tatchi tatchi deleted the fix-#559 branch March 11, 2021 11:52
@mnxn mnxn linked an issue Mar 11, 2021 that may be closed by this pull request
@mnxn mnxn mentioned this pull request Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching implementation/interface is broken
3 participants