godot-vscode-plugin icon indicating copy to clipboard operation
godot-vscode-plugin copied to clipboard

Code highlight stays at same color

Open EduardoJuliao opened this issue 2 years ago • 3 comments

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): image

VSCode (with GDScript color theme): image

Godot: image

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;

EduardoJuliao avatar Dec 27 '23 21:12 EduardoJuliao

Yeah, that's a weird one. I tried your code with 1.3.1 and I see this:

image

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):

image

DaelonSuzuka avatar Dec 29 '23 02:12 DaelonSuzuka

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

image

Now, if I add -> void:, it breaks the highlight.

image

EduardoJuliao avatar Dec 30 '23 01:12 EduardoJuliao

@EduardoJuliao Are you still experiencing this issue since the release of 2.0.0?

DaelonSuzuka avatar Feb 28 '24 04:02 DaelonSuzuka

I am experiencing the same issue. Syntax highlighting breaks if I add a return type after my function declaration.

Armand-Alvarez avatar Jul 27 '24 01:07 Armand-Alvarez

Similar to above, my syntax highlighting breaks when I have a returnt type included in my function declaration. See example below: image

And without the return type declared: image

Armand-Alvarez avatar Jul 27 '24 01:07 Armand-Alvarez

Disregard. I disabled a separate gdscript extension and my syntax highlighting came back.

Armand-Alvarez avatar Jul 27 '24 20:07 Armand-Alvarez

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.

DaelonSuzuka avatar Jul 27 '24 22:07 DaelonSuzuka

Unfortunately I'm also experiencing this issue. No gdextensions, latest VSCode, latest godot-tools, Godot 4.2+ image

Robert-K avatar Aug 01 '24 18:08 Robert-K

@Robert-K Do you mind pasting that code/file into a code box so I can try and reproduce the problem?

DaelonSuzuka avatar Aug 01 '24 19:08 DaelonSuzuka

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)

Robert-K avatar Aug 01 '24 19:08 Robert-K

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.

DaelonSuzuka avatar Aug 01 '24 20:08 DaelonSuzuka