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

Region section is not correctly handled when "#endregion" is set in a string variable inside the region #89115

Closed
TheRealSlander opened this issue Mar 3, 2024 · 4 comments · Fixed by #89242

Comments

@TheRealSlander
Copy link

Tested versions

Godot 4.3 dev 4 (probably previous versions as well)

System information

Manjaro Linux (DE: Cinnamon v6.0.4) 64 bits (but probably all systems)

Issue description

When using the comment regions in a script, if a string inside a region contains "#endregion" alone on a single line, it triggers the region's end prematurely and then messes the region feature.

Steps to reproduce

Copy the following code inside a script and try to fold the region TEST (comments are only there to explain the behavior):

#region TEST
# This region should be folded up to the EOF comment
func test() -> void:
	# Dummy content
	var testing : String = "" 
	# To trigger the region's end, the string must be the first thing on the line, with or without tabs in front
	# Single quoted or literal strings does the same effect
	testing += """
#endregion
"""
	# Some more content which will not be folded with the region!
	var new_var : int = 3
# The real end of the region, when folding TEST we should not see any of the test() method content
#endregion
# EOF comment

The result is a partially folded region (see screenshots below).

Unfolded region:
Capture d’écran du 2024-03-03 16-29-57

Actual folded region:
Capture d’écran du 2024-03-03 16-30-10

Expected result:
Capture d’écran du 2024-03-03 16-42-08

Minimal reproduction project (MRP)

Not necessary.

@TheRealSlander
Copy link
Author

I tested more in depth and if the string is for example "#region REGION_NAME", the corresponding region is created as well.
In short: if the string contains "#region" or "#endregion" it is interpreted as a real region keyword, where it should not be treated at all. Hope this helps.

@dalexeev
Copy link
Member

dalexeev commented Mar 4, 2024

Looks like the editor doesn't take into account language syntax, only comment delimiters. CC @jmb462 @Paulb23

@RafaelRain18
Copy link
Contributor

Hi, I'm new here, can I be assigned to this issue? Or is it already assigned to someone else?

@dalexeev
Copy link
Member

dalexeev commented Mar 4, 2024

@RafaelRain18 Feel free to start working on it. We usually prefer not to assign issues. Your comment is enough to inform other contributors of your intention. If you need help, you can ask in the Godot Contributors Chat. Thanks!

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

Successfully merging a pull request may close this issue.

4 participants