godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.8k stars 21.13k forks source link

Dragging nodes to a C# file in editor handles it as GDScript #91295

Open aki-art opened 6 months ago

aki-art commented 6 months ago

Tested versions

v4.2.2 Stable Mono [15073afe3]

System information

Windows 10 - Godot v4.2.2.stable.mono.official

Issue description

Dragging and dropping a node to the script editor window ignores the currently opened file's language, and inserts a GDScript snippet into the .cs file. Either $ExampleNode, or @onready var example_node = $ExampleNode if done while holding Ctrl.

This is of course invalid code for C#.

Expected behavior: Either insert C# code or just do nothing if the active file's extension does not match .gd

gdscriptursilly

Steps to reproduce

  1. Create and attach a C# script to a node.
  2. Drag and drop any node to the script window, to quick insert a reference to it.

Minimal reproduction project (MRP)

N/A

theraot commented 5 months ago

Last time I was looking at this code I was becoming convinced it needed some redesign. I think it could use some kind of language provider that would be used to generate code for different langauges. But that was beyond the scope of what I was doing (I fixed generating a typed expression, and was working on dragging and dropping a property from the inspector).