From 982f0590c82d305613f5bb6a0316b64a5482d3df Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Wed, 8 Jan 2025 04:42:42 -0800 Subject: [PATCH] fix gdscript 2.0 parsing error when no newline at EOF GDScript 2.0 can have parsing errors if the script does not end with a newline --- bytecode/bytecode_base.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bytecode/bytecode_base.cpp b/bytecode/bytecode_base.cpp index e4e3189e..af2f9cf7 100644 --- a/bytecode/bytecode_base.cpp +++ b/bytecode/bytecode_base.cpp @@ -1132,6 +1132,11 @@ Error GDScriptDecomp::decompile_buffer(Vector p_buffer) { script_text += line; } + // GDScript 2.0 can have parsing errors if the script does not end with a newline + if (bytecode_version >= GDSCRIPT_2_0_VERSION && !script_text.ends_with("\n")) { + script_text += "\n"; + } + if (script_text == String()) { if (identifiers.size() == 0 && constants.size() == 0 && tokens.size() == 0) { return OK;