Commit 52c8285b authored by Kåre Särs's avatar Kåre Särs

Replace QUrl::path() with toLocalPath() for proper paths for the server

Plain path() returns /C:/Users/... in stead of C:/Users/...
That made QProcess fail to start the LSP server.
parent 1e9aebf9
......@@ -176,7 +176,7 @@ class FileLineReader
public:
FileLineReader(const QUrl &url)
: file(url.path())
: file(url.toLocalFile())
{
file.open(QIODevice::ReadOnly);
}
......@@ -1015,7 +1015,7 @@ public:
for (const auto &loc : locations) {
if (loc.uri != lastUrl) {
if (parent) {
parent->setText(QStringLiteral("%1: %2").arg(lastUrl.path()).arg(parent->rowCount()));
parent->setText(QStringLiteral("%1: %2").arg(lastUrl.toLocalFile()).arg(parent->rowCount()));
}
lastUrl = loc.uri;
parent = new QStandardItem();
......@@ -1028,7 +1028,7 @@ public:
fillItemRoles(item, loc.uri, loc.range, loc.kind, snapshot);
}
if (parent)
parent->setText(QStringLiteral("%1: %2").arg(lastUrl.path()).arg(parent->rowCount()));
parent->setText(QStringLiteral("%1: %2").arg(lastUrl.toLocalFile()).arg(parent->rowCount()));
// plain heuristic; mark for auto-expand all when safe and/or useful to do so
if (treeModel->rowCount() <= 2 || locations.size() <= 20) {
......@@ -1372,7 +1372,7 @@ public:
static QStandardItem *getItem(const QStandardItemModel &model, const QUrl &url)
{
auto l = model.findItems(url.path());
auto l = model.findItems(url.toLocalFile());
if (l.length()) {
return l.at(0);
}
......@@ -1463,7 +1463,7 @@ public:
}
topItem = new QStandardItem();
model->appendRow(topItem);
topItem->setText(diagnostics.uri.path());
topItem->setText(diagnostics.uri.toLocalFile());
} else {
topItem->setRowCount(0);
}
......@@ -1485,7 +1485,7 @@ public:
}
auto relatedItemMessage = new QStandardItem();
fillItemRoles(relatedItemMessage, related.location.uri, related.location.range, RangeData::KindEnum::Related);
auto basename = QFileInfo(related.location.uri.path()).fileName();
auto basename = QFileInfo(related.location.uri.toLocalFile()).fileName();
auto location = QStringLiteral("%1:%2").arg(basename).arg(related.location.range.start().line());
relatedItemMessage->setText(QStringLiteral("[%1] %2").arg(location).arg(related.message));
relatedItemMessage->setData(diagnosticsIcon(LSPDiagnosticSeverity::Information), Qt::DecorationRole);
......@@ -1756,7 +1756,7 @@ public:
QSet<QString> fpaths;
for (const auto &view : m_mainWindow->views()) {
if (auto doc = view->document()) {
fpaths.insert(doc->url().path());
fpaths.insert(doc->url().toLocalFile());
}
}
// check and clear defunct entries
......
......@@ -1016,7 +1016,7 @@ private:
// NOTE a typical server does not use root all that much,
// other than for some corner case (in) requests
QJsonObject params {{QStringLiteral("processId"), QCoreApplication::applicationPid()},
{QStringLiteral("rootPath"), m_root.path()},
{QStringLiteral("rootPath"), m_root.toLocalFile()},
{QStringLiteral("rootUri"), m_root.toString()},
{QStringLiteral("capabilities"), capabilities},
{QStringLiteral("initializationOptions"), m_init}};
......@@ -1042,7 +1042,7 @@ public:
qCInfo(LSPCLIENT) << "starting" << m_server << "with root" << m_root;
// start LSP server in project root
m_sproc.setWorkingDirectory(m_root.path());
m_sproc.setWorkingDirectory(m_root.toLocalFile());
// at least we see some errors somewhere then
m_sproc.setProcessChannelMode(QProcess::ForwardedErrorChannel);
......
......@@ -50,13 +50,13 @@ int main(int argc, char **argv)
q.exec();
QObject::disconnect(conn);
auto diagnostics_h = [](const LSPPublishDiagnosticsParams &diag) { std::cout << "diagnostics " << diag.uri.path().toUtf8().toStdString() << " count: " << diag.diagnostics.length(); };
auto diagnostics_h = [](const LSPPublishDiagnosticsParams &diag) { std::cout << "diagnostics " << diag.uri.toLocalFile().toUtf8().toStdString() << " count: " << diag.diagnostics.length(); };
QObject::connect(&lsp, &LSPClientServer::publishDiagnostics, diagnostics_h);
auto document = QUrl(QString::fromLatin1(argv[3]));
QFile file(document.path());
QFile file(document.toLocalFile());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return -1;
QTextStream in(&file);
......
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