Skip to content

Commit 527bc4b

Browse files
committed
Script Window: Attempt to match editor's syntax highlighting
If there is at least one script open in the editor, we can steal its syntax highlighter and apply it to the script window's CodeEdit control. Otherwise, we continue to use a built-in SyntaxHighlighter.
1 parent b7568db commit 527bc4b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

addons/block_code/ui/script_window/script_window.gd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ var script_content: String = ""
66
@onready var script_label: CodeEdit = %Code
77

88

9+
## Attempts to match the syntax highlighting for some open script in the
10+
## editor, which is more likely to be appropriate for the editor theme
11+
## than our hardcoded default
12+
func _apply_editor_syntax_highlighter():
13+
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
14+
for x in script_editor.get_open_script_editors():
15+
var control: Control = x.get_base_editor()
16+
if control is TextEdit:
17+
script_label.syntax_highlighter = control.syntax_highlighter
18+
break
19+
20+
921
func _ready():
22+
_apply_editor_syntax_highlighter()
1023
script_label.text = script_content.replace("\t", " ")
1124

1225

0 commit comments

Comments
 (0)