From a412922c2b9d4b928f758f415224710784a3e499 Mon Sep 17 00:00:00 2001 From: Lamia Date: Sun, 24 Jul 2022 21:42:32 +1000 Subject: [PATCH] LSP: Improve handling of file URI scheme Fixes #63205. (cherry picked from commits 3fa943fe2320f28fd6c7a6910f27cf9c91f41e46, 42a16ef76e4100c285a4a8c17f22a199986072a7 and 2ff69d61813e1176daca5e6baee5e9f6106bf371) --- .../gdscript/language_server/gdscript_language_protocol.cpp | 4 +++- modules/gdscript/language_server/gdscript_workspace.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index ed88fafc8eb..77a6590f2dc 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -183,7 +183,9 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { if (root_uri.length() && is_same_workspace) { workspace->root_uri = root_uri; } else { - workspace->root_uri = "file://" + workspace->root; + String r_root = workspace->root; + r_root = r_root.lstrip("/"); + workspace->root_uri = "file:///" + r_root; Dictionary params; params["path"] = workspace->root; diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 5a53f09e064..d9e4077660b 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -496,9 +496,9 @@ Error GDScriptWorkspace::parse_local_script(const String &p_path) { } String GDScriptWorkspace::get_file_path(const String &p_uri) const { - String path = p_uri; - path = path.replace(root_uri + "/", "res://"); - path = path.http_unescape(); + String path = p_uri.http_unescape(); + String base_uri = root_uri.http_unescape(); + path = path.replacen(base_uri + "/", "res://"); return path; }