From c5aedff514ad2f0de37b787c7143b1a0e91e9025 Mon Sep 17 00:00:00 2001 From: Joonas Ulmanen Date: Wed, 15 Oct 2025 19:59:00 +0300 Subject: [PATCH] LSP: Fix dict[] uses where the key might not exist --- modules/gdscript/language_server/godot_lsp.h | 23 +++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/modules/gdscript/language_server/godot_lsp.h b/modules/gdscript/language_server/godot_lsp.h index 627b4486907..f256e95916c 100644 --- a/modules/gdscript/language_server/godot_lsp.h +++ b/modules/gdscript/language_server/godot_lsp.h @@ -687,9 +687,9 @@ struct TextDocumentItem { void load(const Dictionary &p_dict) { uri = p_dict["uri"]; - languageId = p_dict["languageId"]; - version = p_dict["version"]; - text = p_dict["text"]; + languageId = p_dict.get("languageId", ""); + version = p_dict.get("version", 0); + text = p_dict.get("text", ""); } Dictionary to_json() const { @@ -703,20 +703,9 @@ struct TextDocumentItem { }; /** - * An event describing a change to a text document. If range and rangeLength are omitted - * the new text is considered to be the full content of the document. + * An event describing a change to a text document. */ struct TextDocumentContentChangeEvent { - /** - * The range of the document that changed. - */ - Range range; - - /** - * The length of the range that got replaced. - */ - int rangeLength = 0; - /** * The new text of the range/document. */ @@ -724,8 +713,6 @@ struct TextDocumentContentChangeEvent { void load(const Dictionary &p_params) { text = p_params["text"]; - rangeLength = p_params["rangeLength"]; - range.load(p_params["range"]); } }; @@ -1457,7 +1444,7 @@ struct CompletionContext { void load(const Dictionary &p_params) { triggerKind = int(p_params["triggerKind"]); - triggerCharacter = p_params["triggerCharacter"]; + triggerCharacter = p_params.get("triggerCharacter", ""); } };