Skip to content

Godot's LSP does not return correct path for uid:// resources for textDocument/documentLink command. #105000

Closed
@anthonyme00

Description

@anthonyme00

Tested versions

Not a problem before Godot 4.4

https://godotengine.org/article/uid-changes-coming-to-godot-4-4/

System information

Windows 11 - Godot 4.4.1 Stable

Issue description

This is linked to the following issue on godot-vscode-plugin:
godotengine/godot-vscode-plugin#840

Godot's LSP does not return the correct target if a resource is referenced using uid:// scheme, as can be seen below:

Image

This causes uid:// references to break when using VSCode with godot-vscode-plugin which i've currently worked around by discarding uid:// references coming from the LSP.
Image

A potential fix is by overriding GDScriptWorkplace::get_file_uri p_path with the res:// path if p_path starts with uid://, as can be seen in this diff:

(applied to commit 1f56d96cf2c768c3844c68ccb504dfeee841ae15)

diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index b2e52b7425..c3f99cc42d 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -567,6 +567,9 @@ String GDScriptWorkspace::get_file_path(const String &p_uri) const {
 
 String GDScriptWorkspace::get_file_uri(const String &p_path) const {
 	String uri = p_path;
+	if (p_path.begins_with("uid://")) {
+		uri = ResourceUID::uid_to_path(p_path);
+	}
 	uri = uri.replace("res://", root_uri + "/");
 	return uri;
 }

Image

Steps to reproduce

  1. Use godot with VSCode for editing scripts, using godot-vscode-plugin
  2. ctrl+click on uid:// references
  3. godot-vscode-plugin fails to resolve the reference due to the LSP not returning a valid target and shows an error

Minimal reproduction project (MRP)

not project dependent, but here you go anyway:
lsp-repro.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Bad

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions