Commit fdcf9b3d authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

lspclient: normalize file URL while parsing

parent 20dfb9c7
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QJsonArray> #include <QJsonArray>
#include <QCoreApplication> #include <QCoreApplication>
#include <QTime> #include <QTime>
#include <QFileInfo>
static const QString MEMBER_ID = QStringLiteral("id"); static const QString MEMBER_ID = QStringLiteral("id");
static const QString MEMBER_METHOD = QStringLiteral("method"); static const QString MEMBER_METHOD = QStringLiteral("method");
...@@ -546,6 +547,25 @@ public: ...@@ -546,6 +547,25 @@ public:
} }
}; };
// follow suit; as performed in kate docmanager
// normalize at this stage/layer to avoid surprises elsewhere
// sadly this is not a single QUrl method as one might hope ...
static QUrl
normalizeUrl(const QUrl & url)
{
QUrl u(url.adjusted(QUrl::NormalizePathSegments));
// Resolve symbolic links for local files (done anyway in KTextEditor)
if (u.isLocalFile()) {
QString normalizedUrl = QFileInfo(u.toLocalFile()).canonicalFilePath();
if (!normalizedUrl.isEmpty()) {
u = QUrl::fromLocalFile(normalizedUrl);
}
}
return u;
}
static LSPMarkupContent static LSPMarkupContent
parseMarkupContent(const QJsonValue & v) parseMarkupContent(const QJsonValue & v)
{ {
...@@ -589,7 +609,7 @@ parseRange(const QJsonObject & range) ...@@ -589,7 +609,7 @@ parseRange(const QJsonObject & range)
static LSPLocation static LSPLocation
parseLocation(const QJsonObject & loc) parseLocation(const QJsonObject & loc)
{ {
auto uri = loc.value(MEMBER_URI).toString(); auto uri = normalizeUrl(QUrl(loc.value(MEMBER_URI).toString()));
auto range = parseRange(loc.value(MEMBER_RANGE).toObject()); auto range = parseRange(loc.value(MEMBER_RANGE).toObject());
return {QUrl(uri), range}; return {QUrl(uri), range};
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment