godotengine / godot

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

Dotnet External Editor Option does not support Visual Studio Code Insiders #81738

Open RosstheRoss opened 11 months ago

RosstheRoss commented 11 months ago

Godot version

v4.1.1.stable.mono.official [bd6af8e0e]

System information

Godot v4.1.1.stable.mono - Windows 10.0.25300 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 31.0.15.5009) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Issue description

Attempting to use the Visual Studio Code external editor option with only the Insiders version of Visual Studio Code installed fails with the following error:

modules/mono/glue/runtime_interop.cpp:1324 - Cannot find code editor: VSCode
editor/plugins/script_editor_plugin.cpp:2248 - Couldn't open script in the overridden external text editor

Setting the Custom Exec Path to the location of Code - Insiders.exe does not work either.


This is because VSCode insiders adds -insiders to its binary names. On my system code does not exist but code-insiders does. A hacky workaround would be to symlink code to point to code-insiders which worked on my machine.

The naïve solution would be to add a copy of everything with -insiders to the array below. I have only tried this on Windows but I expect the pattern to be the same on any operating system.

https://github.com/godotengine/godot/blob/5f1e56ff26be4070496aa51095b9ac2f2b4f4ed8/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs#L177

Steps to reproduce

  1. Install Visual Studio Code - Insiders and not the regular Visual Studio Code
  2. Set the External Editor in Editor Settings > Dotnet > External Editor to Visual Studio Code
  3. Open any project that uses C#
  4. Attempt to open any .cs file
  5. The file fails to open

Minimal reproduction project

N/A

RealMadvicius commented 11 months ago

Did you try to setup explicitly the path to the executable of your vscode? From the same menu where you setup with which IDE you want to open scripts, you have another field "custom executable", what happens if you provide your custom visual studio code executable path here ?

JustusPan commented 11 months ago

It's better to support a new option ExternalEditorId.VsCodeInsider independantly, because we may have both code and code-insider installed at same time.

RosstheRoss commented 11 months ago

Did you try to setup explicitly the path to the executable of your vscode? From the same menu where you setup with which IDE you want to open scripts, you have another field "custom executable", what happens if you provide your custom visual studio code executable path here ?

That also does not work, I updated the issue to reflect that.

jfbguy commented 11 months ago

I am able to open with Visual Studio Code Insiders with the Dotnet > Editor Settings:

External Editor: Custom
Custom Exec Path: C:\Users\<UserName>\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe
Custom Exec Path Args: {file}
Editor Path Optional:
blubberdiblub commented 5 months ago

Did you try to setup explicitly the path to the executable of your vscode? From the same menu where you setup with which IDE you want to open scripts, you have another field "custom executable", what happens if you provide your custom visual studio code executable path here ?

That also does not work, I updated the issue to reflect that.

@RosstheRoss

In addition to setting the custom path to the editor you also have to set External Editor to Custom, otherwise the custom path doesn't take effect.

While this may seem obvious to most people, it wasn't obvious to me and I just learned it today.

Coming from Unity, if you have VSCode Insiders you have to point the Unity Editor to your custom path to VSCode first, then it will detect it as a vscode version and you have to make sure you now select this VSCode Insiders version specifically, as a custom editor won't cut it there. With a custom editor selected in Unity you wouldn't be able to create the project/solution files VSCode needs to properly handle the project code. Hence I assumed Godot would work similarly, but it doesn't.

Or in other words: Setting a Custom Exec Path in Godot means the path only for the Custom editor, it doesn't mean a custom path for one of the selected standard editor choices.