diff options
author | thislooksfun <tlf@thislooks.fun> | 2021-10-27 19:45:34 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-02 17:53:22 +0100 |
commit | d4eef0f17d553e9a46eda99a85992c61eb3dba18 (patch) | |
tree | 67ba7ddde121aa4b18a60d94595435b0b5cdcaac /Userland | |
parent | d73d044f2bdefba1ee7eb16f654c09af4d56627c (diff) | |
download | serenity-d4eef0f17d553e9a46eda99a85992c61eb3dba18.zip |
LibGUI: Abstract out and name repeated logic
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp b/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp index de05c2bb77..2c04721376 100644 --- a/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp @@ -155,9 +155,10 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)> identifier_entries.empend("layout: ", partial_input_length, Language::Unspecified, "layout"); }; + bool after_token_on_same_line = last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line(); switch (state) { case Free: - if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) { + if (after_token_on_same_line) { // After some token, but with extra space, not on a new line. // Nothing to put here. break; @@ -168,7 +169,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)> case InClassName: { if (class_names.is_empty()) break; - if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) { + if (after_token_on_same_line) { // After a class name, but haven't seen braces. // TODO: Suggest braces? break; @@ -184,7 +185,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)> break; } case InIdentifier: { - if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) { + if (after_token_on_same_line) { // After an identifier, but with extra space // TODO: Maybe suggest a colon? break; |