mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-16 12:52:46 +00:00
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.
This commit is contained in:
parent
989c111d65
commit
f048d16be5
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue