diff options
author | thislooksfun <tlf@thislooks.fun> | 2021-10-25 20:26:50 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-02 17:53:22 +0100 |
commit | f048d16be55b9023e3dff4d7bcac04f240b74d9f (patch) | |
tree | 994690fbd6f34b60c55ce5d0ccb4f08ad99f1789 /Userland/Libraries/LibGUI | |
parent | 989c111d6557659d5d47e2ad9b17cba9225f1122 (diff) | |
download | serenity-f048d16be55b9023e3dff4d7bcac04f240b74d9f.zip |
LibGUI: Correctly suggest layout classes
Previously when the GMLAutocompleteProvider was invoked just after the
'layout:' tag it would suggest nothing. This is because Layouts do not
inherit from Widget, so the two checks would always eliminate every
suggestion from the list. This patch makes it always suggest any
(registered) object that inherits from GUI::Layout.
This should make layouts more discoverable and easier to quickly use.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp b/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp index 77fe344238..43d9396249 100644 --- a/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp @@ -105,6 +105,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)> } auto& widget_class = *Core::ObjectClassRegistration::find("GUI::Widget"); + auto& layout_class = *Core::ObjectClassRegistration::find("GUI::Layout"); Vector<GUI::AutocompleteProvider::Entry> class_entries, identifier_entries; switch (state) { @@ -190,10 +191,9 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)> break; if (identifier_string == "layout") { Core::ObjectClassRegistration::for_each([&](const Core::ObjectClassRegistration& registration) { - if (!registration.is_derived_from(widget_class)) + if (®istration == &layout_class || !registration.is_derived_from(layout_class)) return; - if (registration.class_name().contains("Layout")) - class_entries.empend(String::formatted("@{}", registration.class_name()), 0u); + class_entries.empend(String::formatted("@{}", registration.class_name()), 0u); }); } break; |