Skip to content

Comments

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

Open
jamesminardi wants to merge 1 commit intogodotengine:masterfrom
jamesminardi:for_loop_highlighting
Open

GDScript: Fix for loop inline body highlighted as type#104507
jamesminardi wants to merge 1 commit intogodotengine:masterfrom
jamesminardi:for_loop_highlighting

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
}

// 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 )* 

@AThousandShips AThousandShips removed request for a team April 18, 2025 14:23
@jamesminardi jamesminardi force-pushed the for_loop_highlighting branch 7 times, most recently from 5e6e906 to 9bd7896 Compare April 24, 2025 20:22
@jamesminardi jamesminardi marked this pull request as ready for review April 24, 2025 20:22
@jamesminardi jamesminardi force-pushed the for_loop_highlighting branch 2 times, most recently from 5dc99b5 to 20115df Compare May 6, 2025 01:56
@jamesminardi jamesminardi force-pushed the for_loop_highlighting branch from 20115df to 463365a Compare May 6, 2025 02:00
@Repiteo Repiteo modified the milestones: 4.5, 4.x Sep 18, 2025
@Repiteo Repiteo requested a review from dalexeev November 19, 2025 01:54
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 syntax highlighting in one-line for loops

3 participants