From 8a92615ba0456844e6368f31be42ecf738ae88e7 Mon Sep 17 00:00:00 2001 From: Magian Date: Tue, 14 May 2024 15:32:47 +0800 Subject: [PATCH] Resolve conflict between shader uniform tooltips "/**" and general annotation "/**/". --- editor/plugins/text_shader_editor.cpp | 2 ++ scene/resources/shader.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 83a17003066..ad6464c6a26 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -313,6 +313,8 @@ void ShaderTextEditor::_load_theme_settings() { const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color"); syntax_highlighter->add_color_region("/**", "*/", doc_comment_color, false); + // "/**/" will be treated as the start of the "/**" region, this line is guaranteed to end the color_region. + syntax_highlighter->add_color_region("/**/", "", comment_color, true); // Disabled preprocessor branches use translucent text color to be easier to distinguish from comments. syntax_highlighter->set_disabled_branch_color(Color(EDITOR_GET("text_editor/theme/highlighting/text_color")) * Color(1, 1, 1, 0.5)); diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 0087a5e7f2f..3bee6d10a4a 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -156,7 +156,7 @@ void Shader::get_shader_uniform_list(List *p_params, bool p_get_gr DocData::PropertyDoc prop_doc; prop_doc.name = "shader_parameter/" + pi.name; #ifdef MODULE_REGEX_ENABLED - const RegEx pattern("/\\*\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/\\s*uniform\\s+\\w+\\s+" + pi.name + "(?=[\\s:;=])"); + const RegEx pattern("/\\*\\*\\s([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/\\s*uniform\\s+\\w+\\s+" + pi.name + "(?=[\\s:;=])"); Ref pattern_ref = pattern.search(code); if (pattern_ref != nullptr) { RegExMatch *match = pattern_ref.ptr();