Skip to content

LSP: Fix file URI handling + warn about workspace project mismatch #104401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HolonProduction
Copy link
Member

@HolonProduction HolonProduction commented Mar 20, 2025

Fixes #103565
Fixes #92248
Fixes #105000

Might have an influence on:
godotengine/godot-vscode-plugin#649
godotengine/godot-vscode-plugin#650

This PR does two things:

  • Replaces the file URI handling from the language server with an implementation based on rfc3986 and rfc8089. So that the URI is properly read and decoded.

  • Do stuff to convert the absolute URI path to a valid res path, taking into account projects in symlinked directories and case insensitive file systems. This should solve a lot of problems with duplicate class name errors when using the language server.

Also adds a warning if the root location of the workspace does not match the project which is open in Godot.

TODO:

  • Test on windows (drive letters might need special handling, since the absolute path from the URI might contain a leading slash before the drive letter. We might need to strip it).

This was only briefly tested on a Windows VM. Further Windows testing might be helpful.

This PR changes the behavior of exposed methods. I'm working under the assumption that the language server is experimental (not the feature, but the exposed API). See #105016

@xelevena
Copy link

On Windows 11 10.0.26100
Using MinGW for compiling

On Visual Studio Code tried load a scene from "C:\Users\11650\Desktop".

Inside Godot editor also open the scene file. Both file change at the same time. Did not see bugs regards driving letters.
image

@Nallebeorn
Copy link
Contributor

Tested this on Windows. I still get the #103565 error about "Hides a global script class" in VS Code, and I see the new warning even when editing the opened project (I launched VS Code from Godot in fact).

get_file_path returns a path like /c:/Users/Name/dev/project-name, just like you said.

@HolonProduction
Copy link
Member Author

Thanks for testing! Sounds a bit like Godot could load such paths, but not make them local to the project. I'll spin up a VM and take a look I guess.

@HolonProduction
Copy link
Member Author

The actual hard part wasn't the leading slash, but dealing with the case insensitive file system. I made some adjustments so that paths should now be correctly mapped to the casing with which they are known to Godot. I did some basic testing in a VM but another round of testing by actual windows users would be appreciated.

@HolonProduction
Copy link
Member Author

I'll mark this as ready for review since I'm done on the code side of things, and my limited testing seemed to work.

@HolonProduction HolonProduction marked this pull request as ready for review April 13, 2025 09:02
@HolonProduction HolonProduction requested review from a team as code owners April 13, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment