🐛 修复路径转换问题
This commit is contained in:
parent
cee6e614bf
commit
41ef82b1aa
|
|
@ -130,6 +130,30 @@ namespace lsp::provider
|
||||||
spdlog::info("Initiated loading for {} workspace folder(s)", workspace_folders.size());
|
spdlog::info("Initiated loading for {} workspace folder(s)", workspace_folders.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UriDecode(const std::string& encoded)
|
||||||
|
{
|
||||||
|
std::string decoded;
|
||||||
|
for (size_t i = 0; i < encoded.length(); ++i)
|
||||||
|
{
|
||||||
|
if (encoded[i] == '%' && i + 2 < encoded.length())
|
||||||
|
{
|
||||||
|
std::string hex = encoded.substr(i + 1, 2);
|
||||||
|
char ch = static_cast<char>(std::stoi(hex, nullptr, 16));
|
||||||
|
decoded += ch;
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
else if (encoded[i] == '+')
|
||||||
|
{
|
||||||
|
decoded += ' ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
decoded += encoded[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Initialize::UriToPath(const protocol::DocumentUri& uri)
|
std::string Initialize::UriToPath(const protocol::DocumentUri& uri)
|
||||||
{
|
{
|
||||||
std::string path = uri;
|
std::string path = uri;
|
||||||
|
|
@ -139,6 +163,7 @@ namespace lsp::provider
|
||||||
if (path.length() > 0 && path[0] == '/')
|
if (path.length() > 0 && path[0] == '/')
|
||||||
path = path.substr(1);
|
path = path.substr(1);
|
||||||
#endif
|
#endif
|
||||||
|
path = UriDecode(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue