Skip to content

Commit d4eef0f

Browse files
thislooksfunawesomekling
authored andcommitted
LibGUI: Abstract out and name repeated logic
1 parent d73d044 commit d4eef0f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Userland/Libraries/LibGUI/GMLAutocompleteProvider.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
155155
identifier_entries.empend("layout: ", partial_input_length, Language::Unspecified, "layout");
156156
};
157157

158+
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();
158159
switch (state) {
159160
case Free:
160-
if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) {
161+
if (after_token_on_same_line) {
161162
// After some token, but with extra space, not on a new line.
162163
// Nothing to put here.
163164
break;
@@ -168,7 +169,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
168169
case InClassName: {
169170
if (class_names.is_empty())
170171
break;
171-
if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) {
172+
if (after_token_on_same_line) {
172173
// After a class name, but haven't seen braces.
173174
// TODO: Suggest braces?
174175
break;
@@ -184,7 +185,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
184185
break;
185186
}
186187
case InIdentifier: {
187-
if (last_seen_token && last_seen_token->m_end.column != cursor.column() && last_seen_token->m_end.line == cursor.line()) {
188+
if (after_token_on_same_line) {
188189
// After an identifier, but with extra space
189190
// TODO: Maybe suggest a colon?
190191
break;

0 commit comments

Comments
 (0)