Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript: Fix for loop inline body highlighted as type #104507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jamesminardi
Copy link

Before
base_small

After
try2_small

Now correctly highlights inline for loop bodies instead of only being highlighted as a typed variable for loop.

@jamesminardi jamesminardi requested a review from a team as a code owner March 23, 2025 09:23
@@ -432,6 +433,11 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
col = member_keywords[word];
}

// Don't highlight for loop inline bodies as types.
if (expect_type && in_for_loop && !class_names.has(word)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, types may not only be registered classes. The highlighter should recognize patterns like:

"for" WS+ Identifier WS* ":" WS* Type

where:

WS ::= " " | "\t"
Identifier ::= ( ID_Start | "_" ) ID_Continue*
Type ::= IdentifierChain ( "[" Type ( "," Type )* "]" )?
IdentifierChain ::= Identifier ( "." Identifier )* 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect text hint color in Godot editor
2 participants