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

Add alternative way of commenting code in GDscript like Visual studio Code #53

Open
tokengamedev opened this issue Oct 31, 2024 · 0 comments

Comments

@tokengamedev
Copy link

Describe the project you are working on

Multiple Projects in 4.3.beta 2

Describe the problem or limitation you are having in your project

In the GDscript Editor if you select a section of code and comment using the shortcut keys like Ctrl+/ or Ctrl+K (windows).
the following happens
The code

func some_func():

	var y :int = 0

	# some changes to y
	for x in 10:
		y += x * 2

the commented code

#func some_func():
#
	#var y :int = 0
#
	## some changes to y
	#for x in 10:
		#y += x * 2
#
	#print(y)

The code commented is not proper to read for everybody. And also commenting the empty line within the code should be optional.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Settings in Editor Settings
An option needs to be added for code commenting in Editor settings to select the VSCode style code commenting as code commented in VScode and code commented in GDscript editor are different.
This setting will give an option to select the way code is commented

  1. Default style - current style
  2. Lowest Indent Style - It will comment based on the lowest indented line like in VScode. Examples given below

Commenting in Code
When code is commented using lowest indent style, the code comment header will start from the selected lines lowest indent line.

# func some_func():

# 	var y :int = 0

# 	# some changes to y
# 	for x in 10:
# 		y += x * 2

# 	print(y)

Similar proposal I have created, in Godot, regarding code commenting godotengine#8211

Adding an extra whitespace after the Commnet line header be optional
Provide a setting to toggle adding a space after the comment line header

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Here are some examples of code commented using Lowest Indent Style

## Example 1 - When first line is lowest indent (func line)

# func some_func():
#	var y :int = 0
#	for x in 10:
#		y += x * 2
#
#	print(y)

## Possibility 2 - When first line is lowest indent (for loop) inside another scope

func some_func():
	var y :int = 0
	# for x in 10:
	#	y += x * 2
	#
	# print(y)

## Possibility 3 - When first line is not lowest indent (assignment line)

func some_func():
	var y :int = 0
	for x in 10:
	#	y += x * 2
	#
	# print(y)

If this enhancement will not be used often, can it be worked around with a few lines of script?

This is used often if you use the in-built editor for scripting. No workaround.

Is there a reason why this should be core and not an add-on in the asset library?

GDscript editor is part of the Core engine modules

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

No branches or pull requests

2 participants