godot icon indicating copy to clipboard operation
godot copied to clipboard

New C# scripts use incorrect syntax highlighting in Godot's script editor

Open zauberparacelsus opened this issue 2 years ago • 8 comments

Godot version

v4.0.rc2.mono.official [d2699dc7a] v4.2.1.stable.mono.official [b09f793f5]

System information

Manjaro Linux, kernel 6.0.19-4

Issue description

The syntax highlighting for C# does not function properly on newly-created C# source code files. There is some syntax highlighting, but it is not correct. Possibly it is trying to use the syntax highlighting for GDScript?

After closing and reopening the newly-created C# source file, the syntax highlighting begins to function after a short delay (1-3 seconds on my system).

Steps to reproduce

  1. Create a new C# file. Its syntax highlighting is incorrect.
  2. Close the new C# file.
  3. Reopen the C# file. Its syntax highlighting is corrected after a short delay

Minimal reproduction project

N/A

zauberparacelsus avatar Feb 16 '23 13:02 zauberparacelsus

This bug is still occurring with Godot 4.1

zauberparacelsus avatar Jul 09 '23 19:07 zauberparacelsus

This bug occured at Godot 4.1.1, Windows x64. Actions with reopen helped

stalker57241 avatar Sep 23 '23 15:09 stalker57241

Still an issue with Godot 4.2.1

zauberparacelsus avatar Dec 14 '23 18:12 zauberparacelsus

Updated the original post with a more accurate description

zauberparacelsus avatar Dec 14 '23 18:12 zauberparacelsus

Tested on: v4.2.2.stable.mono.official [15073afe3]

In addition, on existing C# files (such as copied directly from an addon folder like YarnSpinner for Godot), there is some syntax highlighting but it's not great (comments are not gray, some keywords in blue, using and var is not colored, etc.

image

To force syntax highlight I had to save the file (despite no change), close the file, reopen it and wait 3 seconds. In other words, saving the file seems to make it as if it was our own new file, then we can use the same workaround as with our own files.

image

I have no idea what this intermediate syntax highlighting means, but I'd expect both new and existing files to just open with the complete highlighting, possibly after a short delay if that's really about finding if a class exists in the project (but things like comments should be immediately identified).

hsandt avatar May 08 '24 11:05 hsandt

image This bug is still present in Godot 4.2.2 I used to code a lot in Python IDLE without syntax highlighting, but with C# it's much harder. Saving and re-opening the file doesn't help. I had to restart the entire engine to fix it.

DoroNightOwl avatar May 17 '24 19:05 DoroNightOwl

First time trying to edit C# within the editor personally, saving and reopening seems to work for me on 4.3rc3.

Not sure if it's supported but I'm not getting any intellisense either.

roa-nyx avatar Aug 10 '24 14:08 roa-nyx

I'm also experiencing this on Godot 4.3 mono on windows 11 x64. Steps to reproduce as listed by the OP worked for me. image image screenshots show the same file before saving, closing, and re-opening

percellas avatar Oct 21 '24 21:10 percellas

Can also confirm that this is reproducible in 4.3 on Windows 10 (22H2). Workaround works.

baleutes avatar Jan 22 '25 21:01 baleutes

Can confirm still present in v4.4.1 on Windows 11 both on x86 and arm64.

kbricker8 avatar May 01 '25 18:05 kbricker8

Still present in 4.5 stable.

It also happens if you open an existing script for the first time since restarting Godot.

AmyGilhespy avatar Sep 29 '25 21:09 AmyGilhespy

Still in 4.5.1-stable. Happens if you create a script too

Youg-Otricked avatar Dec 09 '25 02:12 Youg-Otricked

Is Godot dropping support for C#?

If not, why is such a critical bug still not fixed yet?

NeurekaSoftware avatar Dec 09 '25 03:12 NeurekaSoftware

because it probably is sitting on the back burner becuse it is fixed by closing and reopening script. The first thing they would work on for C# would be way more likely to be some form of Intelisense instead of some tiny bug fix that isn't a game changer, just a minor inconvenience.

Youg-Otricked avatar Dec 18 '25 22:12 Youg-Otricked

Godot's internal script editor is not intended to be used in production for C#. Most C# users are used to dedicated C# IDEs and it would be a waste of effort to try to make Godot's script editor be as feature complete as C# IDEs like VS, VS Code or Rider.

It can open C# files like it can open .txt or .json files, but it's not a supported use case. As such this is indeed a very low priority issue.

See the docs on how to configure an external C# IDE: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html#configuring-an-external-editor

akien-mga avatar Dec 18 '25 22:12 akien-mga