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

Commenting code with Ctrl+K now inserts the # in front of the first keyword rather than at the start of the line #83571

Open
mieldepoche opened this issue Oct 18, 2023 · 9 comments

Comments

@mieldepoche
Copy link
Contributor

Godot version

v4.2.beta.custom_build [7f884b4]

System information

linux

Issue description

Commenting a line using Ctrl+K inserts a # in front of the first keyword.
This:

  • is ugly imo, it makes it hard to detect what was mass-commented
  • when commenting a code block, it turns comments inside into doc comments (##) which are coloured differently.
simplescreenrecorder-2023-10-18_19.20.21.mp4

Steps to reproduce

  • Use Ctrl + K

Minimal reproduction project

any script

@mieldepoche mieldepoche changed the title Comment toggling now inserts the # in front of the first keyword rather than at the start of the line Commenting code with <kbd>Ctrl+K</kbd> now inserts the # in front of the first keyword rather than at the start of the line Oct 18, 2023
@mieldepoche mieldepoche changed the title Commenting code with <kbd>Ctrl+K</kbd> now inserts the # in front of the first keyword rather than at the start of the line Commenting code with Ctrl+K now inserts the # in front of the first keyword rather than at the start of the line Oct 18, 2023
@Mickeon
Copy link
Contributor

Mickeon commented Oct 18, 2023

Yeah, this is intentional and is even listed as an improvement. If you think this is undesirable, you may propose to restore the old behavior as an option.

@dalexeev

@dalexeev
Copy link
Member

@Deozaan
Copy link

Deozaan commented Oct 18, 2023

is ugly imo, it makes it hard to detect what was mass-commented

I disagree. I like the change and consider it an improvement. It's easy to see what was mass-commented by the fact that there's a mass of text that is all commented. The old way of adding # to the beginning of each line was ugly, IMO, and made it hard to detect at a glance where the commented out code belonged in context to the rest of the code, since indentation is critical in GDScript.

And also it fixes this problem:

gif_comment_toggle_old

Which has been a real pain point for me the whole time I've been using Godot.

when commenting a code block, it turns comments inside into doc comments (##) which are coloured differently.

I agree that this is undesirable. But I don't really see how to fix this. The naïve approach is just to check if a line is already commented, and if so, don't add another # to it. But when you do use Ctrl-K to un-comment something, how will it know what was a real comment (and therefore should be left alone) and which was code that got commented out (and therefore should have the # removed)?

So IMO while turning a comment (#) into a docstring (##) is undesirable, it is just a minor thing and less bothersome to live with than the old behavior.

@ConteZero
Copy link
Contributor

I agree with @mieldepoche, it's really hard to detect what was mass-commented.

The old behavior wasn't perfect, but it was certainly better than this new one in my opinion.

I hope that an option to use the old behavior will be added in the future

@dc1248
Copy link

dc1248 commented Oct 19, 2023

I like the new way - it doesn't interfere with indenting/dedenting blocks of code.

If a lot of people prefer the old way, please add an option so I can have it the new way! lol

@ConteZero
Copy link
Contributor

Proposal: godotengine/godot-proposals#8211

@Deozaan
Copy link

Deozaan commented Oct 21, 2023

The old behavior wasn't perfect, but it was certainly better than this new one in my opinion.

On the contrary. As shown above, the old way was functionally broken when you had indented lines of code commented out and couldn't uncomment them with the hotkey. The new way finally works properly but can result in undesired visual/stylistic side effects which have minimal to no effect on the actual functionality of the code.

Personally, I don't think it makes sense to include and maintain an option that reverts to behavior that is literally broken. But I'm not against people having the option, as long as the working behavior is the default.

@MuffinInACup
Copy link

As shown above, the old way was functionally broken when you had indented lines of code commented out and couldn't uncomment them with the hotkey.

For me personally it was a feature, not a bug: commented-out code was commented out with a hashtag at the beginning of the line, while actual comments (hints, reminders, todos, etc) were commented at the beginning of the comment. When commenting out a big chunk of code, there was a clear separation, and if an actual comment got caught in the selection, it was still easy to distinguish the comment from the commented-out code. I havent moved to 4.2 yet and I dont know what the interaction is when ctrl+K finds an already commented out line in the selection, but I can already see it being harder to spot the actual comment inside a mass-commented code.

Does anyone use ctrl+k to write actual comments, rather than comment/uncomment chunks of code?

@Mickeon
Copy link
Contributor

Mickeon commented Dec 5, 2023

I personally have it bound closer to my left hand as I toggle code fairly frequently. I do prefer the new behavior as it matches a general convention: A space after "#" for explanations, no space for commented out code.

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

7 participants