Hot reloading with VSCode and also debugging with VSCode

Edit: See my reply two messages below. The main VSCode plugin dev clarified that:

Using debugServer is not supported by this extension.

The currently supported behavior is that you can either launch a debug session from VSCode (with no hot reloading and no Godot editor features) OR you can launch a debug session from the Godot editor.


I’ve tested this with both 4.2.2 and 4.3 rc-1 using the godot-tools VSCode plugin, version 2.0. I am using gdscript, not C#.

I am trying to use hot reloading in VSCode, meaning that I hope to edit a script in VSCode while the game is running and see the change in the game. I am simultaneously trying to use the debugging tools in VSCode.

It appears that hot reloading by editing a script in VSCode does not work if the game is run from VSCode. I run the game from VSCode by pressing F5 (“Start debugging.”) When I do this, however, I can use the nice debugging tools in VSCode.

Hot reloading by editing a script in VSCode does work if the game is run from the Godot editor. However, now the debugging tools in VSCode do not work.

I prefer debugging in VSCode… Is there any way to make it so both hot reloading and debugging work in VSCode? Or can other people do this, so my setup is just wrong?

These settings are enabled, although I don’t think it should matter: “Synchronize Script Changes” in the editor under Debug; and “Auto Reload Scripts on External Change” under Editor Settings > Text Editor.

(I found this recent forum post, but it is discussing hot reloading with gdextension. I found this recent Reddit thread, but seems to really be about scripts reverting, which isn’t a problem I have. I haven’t found a bug report that is recent/current; it’s possible I missed it.)

I’m still poking at this.

Tl;dr: You get different partial functionality with VSCode debugging depending on whether you include the debug and debug server ports in the launch.json file for the VSCode plugin debugger.

I am first opening the editor, then clicking a script icon on a node to open VSCode, and then running from VSCode by going to the debug panel and clicking the green “play” icon. With my current settings, when I run in VSCode, the focus appears to change to the editor, and it looks like the editor is actually starting the game. This is new from my last post, and it is definitely caused by using the launch.json config from the Godot docs, which includes the debug port and debug adapter/server port rather than the “minimal” config in the godot-tools Github readme.

My current settings:
Godot editor version: 4.2.2, Windows
godot-tools plugin for VSCode version: 2.0

In the editor:

  • Debug > Synchronize Scene Changes is checked
  • Editor Settings > Text Editor > Use External Editor is checked. Exec Flags are {project} --goto {file}:{line}:{col}.
  • Editor Settings > Network > Debug > Remote Port is port 6007.
  • Editor Settings > Network > Debug Adapter > Remote Port is port 6006. Sync Breakpoints is checked.
  • Editor Settings > Network > Language Server > Remote Port is 6005, and I’ve checked Enable Smart Resolve, Show Native Symbols in Editor, and Use Thread.

In VSCode, in the settings for the godot-tools plugin:

  • Editor path: C:\dev\Godot_4.2.2\Godot_v4.2.2-stable_win64.exe (I mention this because I once did a test using the 4.2 editor while this path was set to the 4.3 version of the editor, and nothing complained, which is unexpected)
  • I do not have headless LSP checked
  • LSP server host is 127.0.0.1
  • LSP server port is 6005

In VSCode, in the launch.json config (accessed by going to the debug panel and clicking the gear next to the green play button and configuration pulldown):

  • "version": "0.2.0",
  • "name": "GDScript Godot",
  • "type": "godot",
  • "request": "launch",

And additionally, I’ve tested including and not including these three lines from the official docs:

  • "project": "${workspaceFolder}",
  • "port": 6007,
  • "debugServer": 6006,

As I wrote above, if I do not include these three lines, then, when I run the game from VSCode, VSCode itself appears to launch it rather than switching focus to the editor first. I cannot hot reload, meaning that changes to the script do not appear in the game upon save. In VSCode I get my print() statements only through the VSCode debug panel, not in the editor’s output panel, and I can use the VSCode debugger’s Active Scene Tree and inspect nodes. I can use break points, and I can even step into the line that I changed. When I hover over the string variable that I changed, it shows the script’s original value rather than the new value I provided to try to hot reload. Also, in the Godot editor, there is no Remote view available for the scene, and my print() statements do not appear in the output panel.

If I do include these three lines, then, when I run the game from VSCode, focus switches to the editor, which seems to run the scene. I can hot reload by editing a script in VSCode, but I cannot view the Active Scene Tree (it says Scene Tree data has not been requested and clicking the refresh icon does nothing). I can use breakpoints in VSCode, and it shows the call stack and variables in the debug panel. Hovering over a variable in the script does not show the variable value, instead it gives me a little definition of the member variable. My print() output goes to both the editor output window and to VSCode’s debug console.

Perhaps this information is meaningful to someone with better knowledge of how any of this works. My next step will be to clean up this information and make a Reddit post, since I know DaelonSuzuka, who appears to be the main dev of the VSCode plugin, has posted on Reddit before. Also, maybe someone there will point out something wrong with my configuration. Then, I suppose I’ll make a bug report for the plugin in Github, although I’ve never made a bug report before.

Nevermind. The main dev for the godot-tools VSC plugin clarified in an issue thread on GitHub that this is the expected behavior for now:

Using debugServer is not supported by this extension.

The currently supported behavior is that you can either launch a debug session from VSCode (with no hot reloading and no Godot editor features) OR you can launch a debug session from the Godot editor.