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

This commit is contained in:
HolonProduction 2025-03-20 10:24:16 +01:00
parent 019ab8745f
commit d55883b4b1
7 changed files with 170 additions and 18 deletions

View file

@ -171,6 +171,28 @@ void GDScriptLanguageProtocol::_bind_methods() {
Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) {
LSP::InitializeResult ret;
{
// Warn if the workspace root does not match with the project that is currently open in Godot,
// since it might lead to unexpected behavior, like wrong warnings about duplicate class names.
String root;
Variant root_uri_var = p_params["rootUri"];
Variant root_var = p_params["rootPath"];
if (root_uri_var.is_string()) {
root = get_workspace()->get_file_path(root_uri_var);
} else if (root_var.is_string()) {
root = root_var;
}
if (ProjectSettings::get_singleton()->localize_path(root) != "res://") {
LSP::ShowMessageParams params{
LSP::MessageType::Warning,
"The GDScript Language Server might not work correctly with other projects than the one opened in Godot."
};
notify_client("window/showMessage", params.to_json());
}
}
String root_uri = p_params["rootUri"];
String root = p_params["rootPath"];
bool is_same_workspace;