Code highlight stays at same color
Godot version
4.1.1
VS Code version
1.85.1
Godot Tools VS Code extension version
1.3.1
System information
Windows 11
Issue description
In some files the code highlight won't work and will stay at the same color:
VSCode (with github dark color scheme):
VSCode (with GDScript color theme):
Godot:
Steps to reproduce
Copying the code above will have the same issue in different files
func _set_sprite(device_name:String) -> void:
if device_name == InputHelper.DEVICE_XBOX_CONTROLLER:
button_sprite.texture = button_sprites.button_sprites.xbox.interact;
if device_name == InputHelper.DEVICE_PLAYSTATION_CONTROLLER:
button_sprite.texture = button_sprites.button_sprites.ps.interact;
if device_name == InputHelper.DEVICE_SWITCH_CONTROLLER:
button_sprite.texture = button_sprites.button_sprites.switch.interact;
if device_name == InputHelper.DEVICE_SWITCH_JOYCON_LEFT_CONTROLLER:
button_sprite.texture = button_sprites.button_sprites.switch.interact;
if device_name == InputHelper.DEVICE_SWITCH_JOYCON_RIGHT_CONTROLLER:
button_sprite.texture = button_sprites.button_sprites.switch.interact;
if device_name == InputHelper.DEVICE_KEYBOARD:
button_sprite.texture = button_sprites.button_sprites.keyboard.interact;
Yeah, that's a weird one. I tried your code with 1.3.1 and I see this:
I have no idea what's causing this for you or why I can't replicate it. The syntax highlighting has been modified a lot since 1.3.1, and I strongly suspect that this will be fixed in the next version.
Here's what your code looks like to me using the latest build (from PR #559):
I'll wait for the next version and check if it fixes or not, but it's a very weird one.
I was trying to reproduce the code and I have this, the highlight partially works
Now, if I add -> void:, it breaks the highlight.
@EduardoJuliao Are you still experiencing this issue since the release of 2.0.0?
I am experiencing the same issue. Syntax highlighting breaks if I add a return type after my function declaration.
Similar to above, my syntax highlighting breaks when I have a returnt type included in my function declaration. See example below:
And without the return type declared:
Disregard. I disabled a separate gdscript extension and my syntax highlighting came back.
This issue was originally for a previous version of the extension, and all the syntax highlighting has been significantly rewritten since then. Since the original author never confirmed that he's still experiencing this problem, I'm going to consider this resolved.
Unfortunately I'm also experiencing this issue.
No gdextensions, latest VSCode, latest godot-tools, Godot 4.2+
@Robert-K Do you mind pasting that code/file into a code box so I can try and reproduce the problem?
Sure:
@tool
extends Node
# Get the bounds ([min, max]) of the polygon
func get_bounds(polygon: PackedVector2Array) -> Bounds2:
var min_point := Vector2.INF
var max_point := -Vector2.INF
for point in polygon:
min_point = Vector2(min(min_point.x, point.x), min(min_point.y, point.y))
max_point = Vector2(max(max_point.x, point.x), max(max_point.y, point.y))
return Bounds2.new(min_point, max_point)
# Make the polygon's centroid the origin
# Modifies the original
func center_polygon(polygon: PackedVector2Array):
var bounds := get_bounds(polygon)
var center := (bounds.min + bounds.max) / 2
for i in range(polygon.size()):
polygon[i] -= center
It happens on any function with a return type for me. Note that -> uses a ligature with my font (Jetbrains Nerdfont)
Thanks, I'll check it out.
ligature
I'm gonna completely lose my mind if ligatures have somehow been causing these intermittent highlighting problems for years.