diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 5e945cdb2c..7ee1d8e892 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -228,41 +228,15 @@ Variant GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { } if (ProjectSettings::get_singleton()->localize_path(root) != "res://") { + // Show a general warning, which works for all clients. 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.get("rootPath", ""); - bool is_same_workspace; -#ifndef WINDOWS_ENABLED - is_same_workspace = root.to_lower() == workspace->root.to_lower(); -#else - is_same_workspace = root.replace_char('\\', '/').to_lower() == workspace->root.to_lower(); -#endif - - if (root_uri.length() && is_same_workspace) { - workspace->root_uri = root_uri; - } else { - String r_root = workspace->root; - r_root = r_root.lstrip("/"); - workspace->root_uri = "file:///" + r_root; - - Dictionary params; - params["path"] = workspace->root; - Dictionary request = make_notification("gdscript_client/changeWorkspace", params); - - ERR_FAIL_COND_V_MSG(!clients.has(latest_client_id), ret.to_json(), - vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id)); - Ref peer = clients.get(latest_client_id); - if (peer.is_valid()) { - String msg = Variant(request).to_json_string(); - msg = format_output(msg); - (*peer)->res_queue.push_back(msg.utf8()); + // Send gdscript_client/changeWorkspace to prompt client side handling, where supported. (Currently known users: VSCode extension, Rider extension). + notify_client("gdscript_client/changeWorkspace", Dictionary({ { "path", ProjectSettings::get_singleton()->get_resource_path() } })); } } @@ -702,8 +676,6 @@ GDScriptLanguageProtocol::GDScriptLanguageProtocol() { set_method("initialize", callable_mp(this, &GDScriptLanguageProtocol::initialize)); set_method("initialized", callable_mp(this, &GDScriptLanguageProtocol::initialized)); - - workspace->root = ProjectSettings::get_singleton()->get_resource_path(); } #undef SET_DOCUMENT_METHOD diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h index 823e14850f..8bf74697e9 100644 --- a/modules/gdscript/language_server/gdscript_workspace.h +++ b/modules/gdscript/language_server/gdscript_workspace.h @@ -72,9 +72,6 @@ protected: void apply_new_signal(Object *obj, String function, PackedStringArray args); public: - String root; - String root_uri; - HashMap native_members; public: diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.h index 17cb24203e..2f0d7a0f5e 100644 --- a/modules/gdscript/tests/test_lsp.h +++ b/modules/gdscript/tests/test_lsp.h @@ -106,11 +106,6 @@ GDScriptLanguageProtocol *initialize(const String &p_root) { GDScriptLanguageProtocol *proto = memnew(GDScriptLanguageProtocol); TestGDScriptLanguageProtocolInitializer::setup_client(); - Ref workspace = GDScriptLanguageProtocol::get_singleton()->get_workspace(); - workspace->root = absolute_root; - // On windows: `C:/...` -> `C%3A/...`. - workspace->root_uri = "file:///" + absolute_root.lstrip("/").replace_first(":", "%3A"); - return proto; }