Skip to content

Commit

Permalink
GDScript LSP: Fix wrong error checks added in godotengine#39385
Browse files Browse the repository at this point in the history
Reverts `latest_client_id` back to 0, as I misunderstood how the client
IDs are assigned and, without further testing and debugging, I can't
say if this was a bug or a valid default value.
Similarly, a `latest_client_id` of -1 is no longer raising an error.

Fixes godotengine#39548.
  • Loading branch information
akien-mga authored and ChristopheLY committed Jun 22, 2020
1 parent 89b7a57 commit 337430a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
params["path"] = workspace->root;
Dictionary request = make_notification("gdscript_client/changeWorkspace", params);

ERR_FAIL_COND_V_MSG(latest_client_id == -1, ret.to_json(),
"GDScriptLanguageProtocol: Can't initialize as no client is connected.");
ERR_FAIL_INDEX_V_MSG((uint64_t)latest_client_id, clients.size(), ret.to_json(),
ERR_FAIL_COND_V_MSG(!clients.has(latest_client_id), ret.to_json(),
vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id));
Ref<LSPeer> peer = clients.get(latest_client_id);
if (peer != nullptr) {
Expand Down Expand Up @@ -277,11 +275,15 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia
"GDScript LSP: Can't notify client as none was connected.");
p_client_id = latest_client_id;
}
<<<<<<< HEAD
<<<<<<< HEAD
ERR_FAIL_COND(!clients.has(p_client_id));
=======
ERR_FAIL_INDEX((uint64_t)p_client_id, clients.size());
>>>>>>> e34f33711b... GDScript LSP: Fix crash in notify_client
=======
ERR_FAIL_COND(!clients.has(p_client_id));
>>>>>>> 786f4ada35... GDScript LSP: Fix wrong error checks added in #39385
Ref<LSPeer> peer = clients.get(p_client_id);
ERR_FAIL_COND(peer == nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class GDScriptLanguageProtocol : public JSONRPC {

HashMap<int, Ref<LSPeer>> clients;
Ref<TCP_Server> server;
int latest_client_id = -1;
int latest_client_id = 0;
int next_client_id = 0;

Ref<GDScriptTextDocument> text_document;
Expand Down

0 comments on commit 337430a

Please sign in to comment.