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 doc comments in a different color #72751

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Feb 5, 2023

Add text_editor/theme/highlighting/doc_comment_color editor setting and other changes in similar places.

The following CodeEdit API has not changed (normal and doc comments are treated the same):

Preview:

@dalexeev dalexeev requested review from a team as code owners February 5, 2023 10:23
@@ -326,6 +326,11 @@ void CSharpLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
p_delimiters->push_back("/* */"); // delimited comment
}

void CSharpLanguage::get_doc_comment_delimiters(List<String> *p_delimiters) const {
p_delimiters->push_back("///"); // single-line doc comment
p_delimiters->push_back("/** */"); // delimited doc comment
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -944,6 +944,8 @@ void CodeTextEditor::_complete_request() {
Color font_color = completion_font_color;
if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) {
font_color = completion_string_color;
} else if (e.insert_text.begins_with("##") || e.insert_text.begins_with("///")) {
font_color = completion_doc_comment_color;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, when would autocompletion ever use ## or /// as a prefix? And why not /**? I see this already exist for normal comment delimiters, but I don't know where those might appear in autocomplete either...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember comments ever being auto-completed either. But I didn't dare remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MewPurPur
Copy link
Contributor

MewPurPur commented Feb 5, 2023

Code looks great, at least on the GDScript side. I thought maybe we wouldn't want a separate function for comment delimiters, since we for example don't separate different string delimiter functions, but I'll leave details like that up to Paulb or the GDScripters I guess. After all, rn we have only one color for strings.

I think it would be good if the color's RGB was also slightly tweaked instead of just a different alpha. Slight blue tint tends to look nice on comments, or maybe making the color a bit brighter idk

@dalexeev
Copy link
Member Author

dalexeev commented Feb 5, 2023

@MewPurPur That's better?

@MewPurPur
Copy link
Contributor

Maybe others would also want to bikeshed the defaults, but to me this seems perfect

@Calinou
Copy link
Member

Calinou commented Feb 5, 2023

@MewPurPur That's better?

I like this one more; see also #71038.

@dalexeev
Copy link
Member Author

Should comment markers (#79761) be highlighted in doc comments, or only in normal comments?

@MewPurPur
Copy link
Contributor

MewPurPur commented Aug 28, 2023

I say they should.

## TODO Add a note explaining why

@dalexeev
Copy link
Member Author

dalexeev commented Sep 4, 2023

Done.

@dalexeev dalexeev requested a review from a team September 4, 2023 07:33
@tokengamedev
Copy link

Is this going to be part of 4.2?

@Calinou

This comment was marked as outdated.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally (rebased on top of master 6916349), it works as expected. The code and chosen default colors look good to me.

Default Godot 2 Light
Screenshot_20231007_193157 Screenshot_20231007_193224 Screenshot_20231007_193145

Note that folding regions are only created if the comment begins with a single #, so there's no risk of ambiguity with colors (notice the gutter on the left):

image

@tokengamedev
Copy link

Feature freeze is in effect now, so this can only be merged in 4.3 at the earliest.

No issues, glad it is implemented

@YuriSizov YuriSizov modified the milestones: 4.x, 4.3 Oct 9, 2023
@akien-mga akien-mga merged commit 71a8ac4 into godotengine:master Oct 9, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

Feature freeze is in effect now, so this can only be merged in 4.3 at the earliest.

This was pre-approved and we're still before beta 1 so this seemed fine to include in the end.

@akien-mga akien-mga modified the milestones: 4.3, 4.2 Oct 9, 2023
@tokengamedev
Copy link

This was pre-approved and we're still before beta 1 so this seemed fine to include in the end

You have made my day

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.

Separate color option for documentation comments
7 participants