Skip to content

Commit

Permalink
Fix issue manateelazycat#1025, remove message_type from JSONRPC content.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Nov 5, 2024
1 parent 6f08095 commit 7241afe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions core/lspserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,22 @@ def send_response(self, request_id, result, **kwargs):
), **kwargs)

def send_message(self, message: dict):
json_content = json.dumps(message)
# message_type is not valid key of JSONRPC, we need remove message_type before send LSP server.
message_type = message.get("message_type")
message.pop("message_type")

# Parse json content.
json_content = json.dumps(message)
message_str = "Content-Length: {}\r\n\r\n{}".format(len(json_content), json_content)

# Send to LSP server.
self.process.stdin.write(message_str.encode("utf-8")) # type: ignore
self.process.stdin.flush() # type: ignore

# InlayHint will got error 'content modified' error if it followed immediately by a didChange request.
# So we need INLAY_HINT_REQUEST_ID_DICT to contain documentation path to send retry request.
record_inlay_hint_request(message)

message_type = message.get("message_type")

if message_type == "request" and \
not message.get('method', 'response') == 'textDocument/documentSymbol':
log_time("Send {} request ({}) to '{}' for project {}".format(
Expand Down
3 changes: 2 additions & 1 deletion langserver/terraform-ls.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "terraform-ls",
"languageId": "terraform",
"command": [
"terraform-ls"
"terraform-ls",
"serve"
],
"settings": {}
}

0 comments on commit 7241afe

Please sign in to comment.