mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-23 18:51:55 +00:00
LibGUI: Abstract out and name repeated logic
This commit is contained in:
parent
d73d044f2b
commit
d4eef0f17d
Notes:
sideshowbarker
2024-07-18 01:34:50 +09:00
Author: https://github.com/thislooksfun
Commit: d4eef0f17d
Pull-request: https://github.com/SerenityOS/serenity/pull/10642
1 changed files with 4 additions and 3 deletions
|
@ -155,9 +155,10 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
|
||||||
identifier_entries.empend("layout: ", partial_input_length, Language::Unspecified, "layout");
|
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) {
|
switch (state) {
|
||||||
case Free:
|
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.
|
// After some token, but with extra space, not on a new line.
|
||||||
// Nothing to put here.
|
// Nothing to put here.
|
||||||
break;
|
break;
|
||||||
|
@ -168,7 +169,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
|
||||||
case InClassName: {
|
case InClassName: {
|
||||||
if (class_names.is_empty())
|
if (class_names.is_empty())
|
||||||
break;
|
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.
|
// After a class name, but haven't seen braces.
|
||||||
// TODO: Suggest braces?
|
// TODO: Suggest braces?
|
||||||
break;
|
break;
|
||||||
|
@ -184,7 +185,7 @@ void GMLAutocompleteProvider::provide_completions(Function<void(Vector<Entry>)>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InIdentifier: {
|
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
|
// After an identifier, but with extra space
|
||||||
// TODO: Maybe suggest a colon?
|
// TODO: Maybe suggest a colon?
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue