mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 12:17:35 +00:00
LibGUI: Match layout classes even after you start typing
The previous commit fixed the issue with layout classes not being suggested at all, but there was still another issue. Once you started typing the class name a different suggester would take over and only show widgets. This commit makes it so it still only suggests layouts in that situation. This, combined with the last commit, makes autocompleting layouts way more discoverable and user-friendly. :^)
This commit is contained in:
parent
f048d16be5
commit
b0122744a6
1 changed files with 13 additions and 0 deletions
|
@ -29,12 +29,14 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
|
|||
Vector<State> previous_states;
|
||||
bool should_push_state { true };
|
||||
GUI::GMLToken* last_seen_token { nullptr };
|
||||
GUI::GMLToken* last_identifier_token { nullptr };
|
||||
|
||||
for (auto& token : all_tokens) {
|
||||
auto handle_class_child = [&] {
|
||||
if (token.m_type == GUI::GMLToken::Type::Identifier) {
|
||||
state = InIdentifier;
|
||||
identifier_string = token.m_view;
|
||||
last_identifier_token = &token;
|
||||
} else if (token.m_type == GUI::GMLToken::Type::ClassMarker) {
|
||||
previous_states.append(AfterClassName);
|
||||
state = Free;
|
||||
|
@ -129,6 +131,17 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
|
|||
// TODO: Suggest braces?
|
||||
break;
|
||||
}
|
||||
|
||||
if (last_identifier_token && last_identifier_token->m_end.line == last_seen_token->m_end.line && identifier_string == "layout") {
|
||||
Core::ObjectClassRegistration::for_each([&](const Core::ObjectClassRegistration& registration) {
|
||||
if (®istration == &layout_class || !registration.is_derived_from(layout_class))
|
||||
return;
|
||||
if (registration.class_name().starts_with(class_names.last()))
|
||||
identifier_entries.empend(registration.class_name(), class_names.last().length());
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
Core::ObjectClassRegistration::for_each([&](const Core::ObjectClassRegistration& registration) {
|
||||
if (!registration.is_derived_from(widget_class))
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue