godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.47k stars 148 forks source link

Preload file does not exist #634

Closed DontStopThinking closed 3 months ago

DontStopThinking commented 3 months ago

Godot version

4.2.1-stable

VS Code version

1.87.2

Godot Tools VS Code extension version

2.0.0

System information

Windows 11

Issue description

I have a GDScript file that is not attached to any node and just contains a static function:

# In test_utils.gd
static func test_function() -> void:
    print("This is a static function")

I then import this file in other scripts like so:

const TestUtils = preload("res://game/scripts/test_utils.gd")

This works fine in Godot itself. However, it appears that the extension does not recognize that this file exists and complains: test_utils_file_explorer

preload_file_does_not_exist

Also notice that the file path does not appear in the intellisense dropdown: test_utils_not_shown_in_dropdown Here, player.gd, which is attached to a node, appears fine in the dropdown.

Steps to reproduce

DontStopThinking commented 3 months ago

Okay, after another try, turns out I had two Godot editors open with two separate projects when I got this error. And it seems the extension was speaking to the wrong editor which is why it couldn't find test_utils.gd, which only existed in one project.

Both of my projects had similar folder structure which is why I didn't realize that it was actually speaking to the wrong editor! Apologies for the confusion, I'll close this issue.