From 280e99073bb2415f52c991f1ffbc658a1056e521 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 8 Apr 2022 17:42:15 +0300 Subject: [PATCH] LibGUI: Stop dropping comments between children and end of GML objects Any left-over comments in the pending_comments vector are now inserted as sub object children, as these are serialized last and will therefore show up in their expected location. --- Userland/Libraries/LibGUI/GML/Parser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibGUI/GML/Parser.cpp b/Userland/Libraries/LibGUI/GML/Parser.cpp index 8e6cfcd71b..169f24c8b9 100644 --- a/Userland/Libraries/LibGUI/GML/Parser.cpp +++ b/Userland/Libraries/LibGUI/GML/Parser.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2020, Andreas Kling * Copyright (c) 2022, kleines Filmröllchen + * Copyright (c) 2022, Idan Horowitz * * SPDX-License-Identifier: BSD-2-Clause */ @@ -91,6 +92,10 @@ static ErrorOr> parse_gml_object(Queue& tokens) } } + // Insert any left-over comments as sub object children, as these will be serialized last + while (!pending_comments.is_empty()) + TRY(object->add_sub_object_child(pending_comments.take_first())); + if (peek() != Token::Type::RightCurly) return Error::from_string_literal("Expected }}"sv);