Skip to content

Make comments starting with #mark and #region visible in Script Editor's Minimap #107762

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vaner-org
Copy link
Contributor

@vaner-org vaner-org commented Jun 20, 2025

Closes #9742.
Allows comments starting with #mark and #region to be visible as text in the Script Editor's Minimap.

minimap

Draft progress:

  • #mark Description support
  • #region Description support
  • Increased line height
  • Respect indentation
  • Accurate visible area rectangle
  • Minimap overflow
  • Script editor overflow
  • Accurate viewport offset
  • Accurate hovering and dragging
  • Unique syntax highlighting for #mark, managed via Editor setting
  • Override color with comment marker colors (Critical, Warning, Notice)

Trying to commit to as few files as possible until I work through this. Any feedback is welcome.

@RedMser
Copy link
Contributor

RedMser commented Jun 20, 2025

Thanks for contributing!

Note that you are likely implementing this in the "wrong" place, since TextEdit is not only used for code (as well as the need to support other programming languages).
The hard-coded #mark string will likely cause problems.

To begin, a quick overview of the relevant class hierarchy, as I understand it:

  • TextEdit is a class that game projects can also use, which is primarily intended for general-purpose multi-line text editing.
  • A sub-class CodeEdit is specialized at editing code of any kind (not just GDScript code). Also exposed for use in game projects.
  • Editor-only classes like CodeTextEditor, TextEditor, ScriptTextEditor, or ScriptEditor, are where most script editor features are implemented. I can't really tell you their differences, or which one is best suited for which tasks.

My recommendation on how the implementation should look (not saying it's The Way, but I think it's at least better than how you're doing it):

  • Since the minimap is part of TextEdit, there should be a new general-purpose API like TextEdit.set_line_minimap_mark(line: int, mark: String) and a corresponding get function. This allows anyone in any project to insert a readable text in the minimap, without depending on the text content. Might need a clear_minimap_marks() function as well, for when the text editor contents are replaced, to avoid having to loop over all line indices.
  • In CodeEdit, you add a new property minimap_mark_strings: Array[String]. If a commented line is found (using is_in_comment maybe?), all of these strings in the array are checked one by one, and if any is matching, then the remaining text of the line is automatically treated as a minimap mark and uses the TextEdit API to register it.
  • Godot's Script Editor code (not sure which file is best for this responsibility) would then fill this new property's value, e.g. based on an EditorSetting (defaults to ["mark"]).

I think an approach like this would make it most flexible for end users, while still providing the same functionality as what is proposed.

Of course, you could think to skip the CodeEdit API and directly have the script editor call the new TextEdit APIs.
But it doesn't seem to reduce complexity, while making the feature unavailable to more projects.

@vaner-org
Copy link
Contributor Author

vaner-org commented Jun 20, 2025

Thank you, this is exactly the kind of guidance I was hoping for. Currently getting my bearings, once I feel comfortable with the feature set, I will rebuild my commit with all of this in mind.

@vaner-org vaner-org force-pushed the minimap-mark-comments branch 2 times, most recently from 947fbe6 to 45fd84d Compare June 21, 2025 04:19
@vaner-org vaner-org changed the title Make comments starting with "#mark" visible in Script Editor's Minimap Make comments starting with #mark and #region visible in Script Editor's Minimap Jun 21, 2025
@vaner-org vaner-org force-pushed the minimap-mark-comments branch 6 times, most recently from e328212 to 0b8b828 Compare June 22, 2025 04:08
@enetheru
Copy link
Contributor

I see changes being pushed, you gotta add some setting in there somewhere.
I dont want to have type multiple types of marks to get the headings showing up in different editors, so being able to change settings to allow the pre-existing conventions of MARK: at any indentation, with the remainder of the line being used for the heading would be how I want to set things up.

@vaner-org
Copy link
Contributor Author

vaner-org commented Jun 22, 2025

See Calinou's comment in the proposal. I'm in agreement with him, and would prefer to follow convention. In your case, isn't this the responsibility of CodeGlance Pro when they add GDscript support? Same as they do for other languages.

@vaner-org vaner-org force-pushed the minimap-mark-comments branch 7 times, most recently from 5a82ce6 to 5e40ad6 Compare June 22, 2025 14:28
@vaner-org vaner-org force-pushed the minimap-mark-comments branch from 5e40ad6 to 0407379 Compare June 23, 2025 05:28
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.

Enlarge special comments in minimap (like "MARK:" in Xcode and VSCode)
4 participants