diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-06-15 14:27:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 14:27:41 +0200 |
commit | e720118a756ce193142362546c71ecb82a700f20 (patch) | |
tree | c756f8824d18a1bf5e292ee1ca287f96f8f5b6d4 | |
parent | 1642effe5bf2f208ca7ef55b7246069d2e8cf23c (diff) | |
parent | 786f4ada35a491fb75cdb14f2f34085e4adb8668 (diff) |
Merge pull request #39556 from akien-mga/lsp-fix-39548
GDScript LSP: Fix wrong error checks added in #39385
-rw-r--r-- | modules/gdscript/language_server/gdscript_language_protocol.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/language_server/gdscript_language_protocol.h | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 8a805196a1..2a67d2ff4f 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -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) { @@ -277,7 +275,7 @@ 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; } - ERR_FAIL_INDEX((uint64_t)p_client_id, clients.size()); + ERR_FAIL_COND(!clients.has(p_client_id)); Ref<LSPeer> peer = clients.get(p_client_id); ERR_FAIL_COND(peer == nullptr); diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h index 564878313d..cf5242e8c5 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.h +++ b/modules/gdscript/language_server/gdscript_language_protocol.h @@ -70,7 +70,7 @@ private: 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; |