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

Highlight TODO, FIXME and similar keywords in comments in the script editor #4942

Closed
Calinou opened this issue Jul 21, 2022 · 4 comments · Fixed by godotengine/godot#79761
Closed
Milestone

Comments

@Calinou
Copy link
Member

Calinou commented Jul 21, 2022

Describe the project you are working on

Related to #602 and #3845.

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Not a particular limitation, but a quality of life feature for the script editor.

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

Other editors such as Visual Studio Code highlight keywords commonly used for important notes and todos. Here's an example with commonly used keywords in the Python language:

With : Without :
image image

Some editors will also highlight the entire line, but this is more complex to implement, especially if you want to handle continuation lines like this:

# TODO: This is a thing that should be done for a future version of the game.
#       This line is still highlighted as TODO due to the spacing.
#
# This comment is not highlighted as TODO.
File contents - Copy-paste this in various editors for testing purposes
# todo: Example comment.
# TODO: Example comment.
# FIXME: Example comment.
# fixme: Example comment.
# NOTE: Example comment.
# note: Example comment.
# CHANGED: Example comment.
# changed: Example comment.
# HACK: Example comment.
# hack: Example comment.
# XXX: Example comment.
# xxx: Example comment.

# todo Example comment.
# TODO Example comment.
# FIXME Example comment.
# fixme Example comment.
# NOTE Example comment.
# note Example comment.
# CHANGED Example comment.
# changed Example comment.
# HACK Example comment.
# hack Example comment.
# XXX Example comment.
# xxx Example comment.

Note: Unlike #602, this proposal does not suggest adding a bottom panel to track all TODOs/FIXMEs within the project. It only suggests highlighting those keywords in comments in the script editor. Project management tools such as issue trackers or Kanban boards are usually more suited for long-term TODO/FIXME tracking.

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

Highlight specific keywords in comments only, but probably don't bother with highlighting the entire line (as handling multiline comments is difficult).

I'd suggest supporting the following keywords for highlighting: TODO, FIXME, NOTE and HACK (all case-sensitive). Like in Visual Studio Code, these do not have to be at the beginning of a comment line, and these do not have to be followed by a : symbol.

XXX ("dirty hack") is rarely used nowadays, so there's probably not much point in supporting it. I haven't seen it in years myself 🙂

From an implementation perspective, I haven't found a way to add a keyword highlight that works within a color region (i.e. comments). Let me know if you can find a way to work around this.

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

No.

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

This is about improving the script editor usability and bringing its functionality on par with popular IDEs.

@fire-forge
Copy link

Another way to implement this would be to add an editor setting of an array of strings to highlight. The default value would have TODO, FIXME, NOTE, and HACK, but then users could add or remove other words if they want. That would solve the same problem but in a more flexible way.

@Calinou
Copy link
Member Author

Calinou commented Jul 21, 2022

Another way to implement this would be to add an editor setting of an array of strings to highlight. The default value would have TODO, FIXME, NOTE, and HACK, but then users could add or remove other words if they want. That would solve the same problem but in a more flexible way.

I don't think the keywords should be made configurable, so that they can also be reliably highlighted by external editors (most importantly, VS Code). External editors generally won't bother reading the project.godot file to determine which keywords should be highlighted.

I know this isn't ideal for people writing comments in non-English languages, but I would prefer people to use consistent syntax whenever possible.

@seppoday
Copy link

Can't we do both (if possible)?

  • Dafault 4 values for internal and external editors
  • Possibility to add your own keywoards via settings for non-english people and for editors that want to use it

if it will be too much work then 4 defaults are totally fine.

@dalexeev
Copy link
Member

dalexeev commented Feb 5, 2023

We can use this list as a basis.

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

Successfully merging a pull request may close this issue.

5 participants