From 1474ecc121b2587283d99a1c0b12716ed9187d12 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Thu, 7 Nov 2024 12:22:55 -0600 Subject: [PATCH] Expose the `EditorScriptHighlighter::_create()` method to GDExtension --- doc/classes/EditorSyntaxHighlighter.xml | 6 ++++++ editor/plugins/script_editor_plugin.cpp | 11 ++++++++--- editor/plugins/script_editor_plugin.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/classes/EditorSyntaxHighlighter.xml b/doc/classes/EditorSyntaxHighlighter.xml index 3685907574..1e67dbd80d 100644 --- a/doc/classes/EditorSyntaxHighlighter.xml +++ b/doc/classes/EditorSyntaxHighlighter.xml @@ -10,6 +10,12 @@ + + + + Virtual method which creates a new instance of the syntax highlighter. + + diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 2edc096382..d40dbabbce 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -86,9 +86,13 @@ PackedStringArray EditorSyntaxHighlighter::_get_supported_languages() const { Ref EditorSyntaxHighlighter::_create() const { Ref syntax_highlighter; - syntax_highlighter.instantiate(); - if (get_script_instance()) { - syntax_highlighter->set_script(get_script_instance()->get_script()); + if (GDVIRTUAL_IS_OVERRIDDEN(_create)) { + GDVIRTUAL_CALL(_create, syntax_highlighter); + } else { + syntax_highlighter.instantiate(); + if (get_script_instance()) { + syntax_highlighter->set_script(get_script_instance()->get_script()); + } } return syntax_highlighter; } @@ -98,6 +102,7 @@ void EditorSyntaxHighlighter::_bind_methods() { GDVIRTUAL_BIND(_get_name) GDVIRTUAL_BIND(_get_supported_languages) + GDVIRTUAL_BIND(_create) } //// diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 5de0aaa1e9..4190110248 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -62,6 +62,7 @@ protected: GDVIRTUAL0RC(String, _get_name) GDVIRTUAL0RC(PackedStringArray, _get_supported_languages) + GDVIRTUAL0RC(Ref, _create) public: virtual String _get_name() const;